This content has been marked as final. Show 5 replies
nameNavClip["NavMviClp" + i] has no way to know it's the i-th movieclip unless you store a value of i somewhere (that's retrievable) before the for-loop increments.
Thanks very much kglad, working as expected now! Just so I know for future reference:
The onRelease function was existing local to the movie clip's scope, so setting ivar local to the movie clip (and assigning it the current value of i when it's created) allowed the onRelease function to reference it and select the appropriate value from the array, correct? (I apologise if that question wasn't totally clear).
the issue is not scope. the issue is the value of i when your movieclip button is released.
if you use trace(i) within your onRelease handler you'll see it's defined (and the last value of your for-loop). so, it's not a scope issue.
the issue is, you don't want the value of i when the button is released. you want the value of i when the onRelease handler was created.
I understand now. The value of i at that point in the code is the value of i in the last iteration of the loop which is one more than the length of the array. Therefore, when I tested the movie, my onRelease was trying to retrieve an array element that didn't exist so I got "undefined" as the value.
I think I got it now, thanks again!