flash cs5:当我更改影片剪辑中的帧时,指向前一帧中一个对象的事件侦听器将被删除
我有一个包含两个帧的影片剪辑,每个帧包含一组不同的按钮。
看来我无法将事件侦听器添加到不在我当前查看的框架中的按钮。
所以..问题一:有没有办法向影片剪辑中的所有元素添加事件侦听器,即使这些元素位于不同的帧中。
问题二:在我向当前帧中的某些元素添加事件侦听器然后前进到下一帧并返回到同一帧后,所有事件侦听器都被删除,我需要再次初始化它们。有没有办法解决问题而不需要重新初始化事件侦听器?
感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.