actionscript-3 - AS 3 游戏结束屏幕闪光倒计时器

标签 actionscript-3 flash countdowntimer

我目前正在学习 ActionScript 3 的 Flash 游戏编程类(class),但似乎无法在任何地方找到可以倒计时然后执行 Action 的时钟。我一直在使用 Lynda 教程,但这没有帮助,我也在谷歌上搜索了很多,但没有运气。我有一个倒计时时钟,并尝试过“if”语句,但没有运气。

有人可以指导我正确的方向吗?我做错了什么?

 //game timer

 var count:Number = 60; // amount of time 

 var myTimer:Timer = new Timer(1000,count); // time in ms, count is calling from line above

 myTimer.addEventListener(TimerEvent.TIMER, countdown);

 myTimer.start();

 function countdown(event:TimerEvent):void
 {
     myText_txt.text = String((count)-myTimer.currentCount); //dynamic txt box shows current count 
 }


 //if and else if statements

 if (((count)-myTimer.currentCount) == 58)
 {
     gotoAndStop(2);
 }

最佳答案

这应该有帮助;)没有任何神奇的数字。

var myTimer:Timer = new Timer(1000,60); // every second for 60 seconds
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
myTimer.start();

function onTimer(e: TimerEvent):void {
    myText_txt.text = String(myTimer.repeatCount - myTimer.currentCount);
}

function onComplete(e: TimerEvent):void{
    gotoAndStop(2);
}

关于actionscript-3 - AS 3 游戏结束屏幕闪光倒计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22141106/

相关文章:

javascript - 如何根据 javascript 变量动态更改 facebook 评论插件 url?

java - 如何重置 CountDownTimer 而不必先暂停

c# - Unity Slider 减少作为定时器

android - 如何仅通过 GPS 读数确定方向并以 360 度显示?

javascript - 外部接口(interface)。 addcallback 在本地有效,但在服务器上无效?

javascript - AngularJS/Flash(如何在 angular html partial 中嵌入 flash 视频)

javascript - 是否有任何JavaScript或Flash项目可以在线编辑音频?

java - 如何在 recyclerview 元素中设置固定的 CountDownTimer?

flash - Flash 是否支持泛型(强类型集合或数组)?

xml - AS3 按子值从 XML 中删除子节点