-->

flash cs5: when i change frames in a movieclip, ev

2019-09-05 22:30发布

问题:

I have a movieclip that contains two frames, each frame contains a different set of buttons.

it seems that i cannot add the event listeners to buttons that are not in my current viewed frame.

so.. problem one: is there a way to add event listeners to all the elements in the movieclip even if the elements are in a different frame.

problem two: after I added an event listener to some elements in current frame and then I move forward to the next frame and go back to the same frame, all the event listeners are removed and i need to initialize them again. is there a way to resolve the issue without the need to re-initialize the event listeners ?

thank you for your help!

回答1:

I don't think so, but..

The way I worked around this problem was pretty simple. I put the event listener intializing code in the timeline, specifically on the frame that contains the element that dispatches the event.

It solves both of your problems. The listeners will only be active, when you're on that specific frame.