Hi everyone,
I have another question about my For loop. I am designing and coding a navigation menu at the moment, and so far I have got the button instances to duplicate for each of the menu items, and set widths, positioning values and RollOver/RollOut functions. However, I would ideally like to include the onRelease button functions in the for loop too - as they are all the same apart from the variable “i”. Here is the code snippet:
for (i=1;i<(_root.noofmenuitems+1);i++){
duplicateMovieClip("mc", "mc"+i, i);
...
this["mc"+i].onRelease = function(){
_root.currentnumber = *;
trace("test "+*);
}
}
Now my problem is that by the time the onRelease function is called, the for loop has been completed and the value of i returned is the last i value from the loop (_root.noofmenuitems+1). The this[“mc”+i] part obviously works, because the trace function is called when I click any of the menu items.
The problem is that I have 6 menu items, and when I click any of them, the trace function returns “test 7” - not the corresponding i values for each button.
Is there any way that I can solve this?
Thanks in advance for any replies,
Andy