flash cs5: when i change frames in a movieclip, event listeners pointed to one object in the previous frame are removed

时光毁灭记忆、已成空白 提交于 2019-12-12 03:53:27

问题


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.



来源:https://stackoverflow.com/questions/3977465/flash-cs5-when-i-change-frames-in-a-movieclip-event-listeners-pointed-to-one-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!