This content has been marked as final. Show 6 replies
there are several problems with your code. the first three are:1 person found this helpful
the onEnterFrame handler executes repeatedly. i know it "sounds" like it should execute once when the playhead enters the frame that contains your code but that's not how it works.
for code that you want to execute once when the frame is played, just attach it to the frame. for code that you want to loop repeatedly, use the onEnterFrame handler (or some other looping function like setInterval() ).
next, your onPress method does not reference your buttons. so, you'll probably end up defining an onPress method for the timeline that contains that code.
next, your buttons have no way to remember or retrieve anything about the value of i when their onPress method was defined.
Superb, the code works like a dream, thanks.
I am still in the dark to why it works as yet, but im gonna figure out that right now.
I cant figure out how "this["btn"+i].ivar=i " part is working?
To me, it looks like your referencing a MC within one of my btn MCs called ivar!! (or something along those lines of thought...)
I take it what is happening here is you are creating some sort of variable (ivar) to store what number button was pressed, and using this to direct to the relevant jpg?
Thanks for your time,
that's correct! ;) he's putting the number of the button inside the button (this is ivar) to make the button 'remember' where to go... so, in every button there is a variable called ivar, kind of a serial number for the button.1 person found this helpful
that's not "...referencing a MC within one of my btn MCs called ivar...". it's storing the value of i in ivar when the mouse handler of this["btn"+i] is created.1 person found this helpful
that's always applicable when using a loop to define a mouse handler when the mouse handler must retrieve information (like the button number) after the loop completes.
in your situation you could also use the flash string methods to retrieve the button in the mouse handler, but that's not always applicable.