Control Array

3 posts

Flag Post

I am trying to create what is called a control array in visual basic, basically i have a bunch of movieclips with names containing numbers which i would like to loop through.

Here is what I have got so far;

for(a=1;a<6;a++){
_root[’die’+a].onPress=function(){
trace(’hello ’+a);
}
}

But it always says ‘hello 6’. So basically i would like a way of passing the index to the function without writing the function five times.

 
Flag Post

try sth like:
bq. for(a=1;a<6;a++){
_root[’die’+a].myA=a;
_root[‘die’+a].onPress=function(){ trace(’hello ’+ this.myA); } }

 
Flag Post

thank you, worked perfectly :)