Flash CS5:当我更改动画片段中的帧时,指向前一帧中一个对象的事件侦听器将被删除 [英] flash cs5: when i change frames in a movieclip, event listeners pointed to one object in the previous frame are removed

查看:125
本文介绍了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 ?

感谢您的帮助!

推荐答案

我不这么认为,但是..

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.

这篇关于Flash CS5:当我更改动画片段中的帧时,指向前一帧中一个对象的事件侦听器将被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆