Edit: it doesn’t appear to be working. Re-thinking what you said about the code only being run once, I think it might be where I put the code. The code is in a function that is being called every frame. I think this might be causing my errors. The loop always outputs the maximum value
[FONT=Courier New][LEFT]
x = 0;
while(x < 9)
{
_root.menu["abbut"+x].onPress = function() {
_root.btnnum = x;
_root.selSpell(_root.btnnum);
trace(x); // always outputs 9
break; // thought it might help to break the loop
}
x++
}// using a while loop out of preference
onLoad=function(){
x = 0;
while(x < 9)
{
_root.menu["abbut"+x].onPress = function() {
_root.btnnum = x;
_root.selSpell(_root.btnnum);
trace(x); // always outputs 9
break; // thought it might help to break the loop
}
x++
}// using a while loop out of preference
}
also im not sure how the scope should be since i never use _root[] in a nested clip so maybe someone else could clear that up
Neither of those solutions seem to be working for me unfortunately. I might consider just taking an “if it ain’t broke, don’t fix it” approach to this, as much as I hate redundant code…
thats the part i ment good job nathan99 lol, @defective thats the same code i wrote except that you put a pointer too _root.menu[“abbut”+i] instead of just writing , which makes no difference :pleased: