views:

19

answers:

1

Hello,

I have a basic for loop to loop through buttons and set some stuff and onPress handlers:

for (i=1;i<=20;i++){
  //do some stuff
  _root["button"+i].onPress = function(){ someMC.gotoAndStop(i+1); }
}

However, as I noticed, all buttonsthen link to one and same frame - all point to last i + 1 - Is there any possibility to call gotoAndStop with "static" Number, so in next iteration, it won't change?

Edit: Ex. for last statement:

Iteration 5 will call gAS /*gotoAndStop:]*/(6);
Iteration 6 -> gAS(7);
Iteration 7 -> gAS(8);
A: 

Nevermind, I solved it with object properties:

for (i=1;i<=20;i++){
  //do some stuff
  _root["button"+i].someproperty = i+1;
  _root["button"+i].onPress = function(){ someMC.gotoAndStop(this.someproperty); }
}
Adam Kiss