Actionscript 3.0 - 用一个按钮改变不同帧的倒计时时间(Actionscript 3.0 -change the countdown time from a different frame with a button)

我有一个倒计时器在我的一个框架上,还有另一个框架上的两个按钮。 我想根据点击的按钮更改计时器。 例如:1分钟3分钟。 我还有一个导航按钮,可以放到定时器放置的框架上。任何想法?

i have a countdown timer on one of my frames and also two buttons on another frame . I want to change the timer based on the button clicked . For example : 1 min 3 min . I also have a navigation button which goes to the frame that the timer is placed.Any ideas?

最满意答案

传播此类事件的最佳方式是在单击按钮时调度自定义事件,而具有计时器的框架应该正在监听该事件。

为此,您可以扩展默认的“Event”类并创建自定义事件类型,以便定时器框架将EventEventListener添加到该事件类型,并且当按下该按钮时,应该调用新事件类型的dispatchEvent。

或者,您可以重新使用任何可用的事件,例如按下按钮1时发送更改事件。

希望这有帮助,祝你好运。

The best way to propagate such event is by dispatching custom event when the button is clicked, while the frame that has the timer should be listening to that event.

To do so, you can extend the default "Event" class and create your custom event type that the timer frame should addEventListener to it and when the button is pressed, a dispatchEvent of the new event type should be called.

Or you can reuse any of the available events, for example when button1 is pressed, dispatch change event.

Hope this helps, goodluck.

更多推荐