PDA

View Full Version : Array [i] triggers Array2 [i]


krone
05-08-2005, 07:48 AM
hello.
this might be a silly question i dont know, but here it is nonetheless
the code i have so far (not working)

for (i = 0; i <100; i++)
{
_root.butArray[i].onRelease = function (){
_root.holderMC.loadMovie (imgArray[i]);
}
}

butArray = instance names of the buttons
imgArray = names of the images to load
holderMC = empty mc

i want butArray[0] to load imgArray[0]
butArray[1] to load imgArray[1]
butArray[2] to load imgArray[2] and so on...

cheers
ooh emoticons.. :cool:

senocular
05-08-2005, 08:19 AM
not silly, a lot of people have this problem ;)

see:
http://www.senocular.com/flash/tutorials/faq/#loopfunctions

Welcome to the forums :D

krone
05-08-2005, 08:32 AM
cheers moit =XD

krone
05-08-2005, 08:50 AM
var cur_button;
for (i = 0; i < 100; i++)
{
cur_button = this["h" + i];
cur_button.num = i;

_root.butArray[i].onRelease = function (){
_root.holderMC.loadMovie (imgArray[num]);
}
}

i MUST be doing something wrong :eek: