This content has been marked as final.
Show 4 replies
-
1. Re: Make a timer
Ned Murphy Mar 14, 2013 9:26 AM (in response to mentalcase129)Search Google or even these forums using terms like "AS3 countdown tutorial"
-
2. Re: Make a timer
Andrei1 Mar 14, 2013 3:43 PM (in response to mentalcase129)The example below displays countdown from 2 minutes to zero.
import flash.display.Sprite; import flash.events.TimerEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.utils.Timer; var countDownDisplay:TextField; var timer:Timer; var date:Date; init(); function init():void { countDownDisplay = new TextField(); countDownDisplay.defaultTextFormat = new TextFormat("Arial", 120, 0x008040); countDownDisplay.multiline = countDownDisplay.wordWrap = false; countDownDisplay.border = true; countDownDisplay.autoSize = "left"; countDownDisplay.x = countDownDisplay.y = 20; countDownDisplay.text = "00:00 "; addChild(countDownDisplay); date = new Date(1000 * 120); timer = new Timer(500); timer.addEventListener(TimerEvent.TIMER, onTimer); timer.start(); } function onTimer(e:TimerEvent):void { date.time -= timer.delay; countDownDisplay.text = date.toUTCString().match(/\d\d:\d\d\s/)[0]; if (date.time <= 0) { timer.stop(); } } -
3. Re: Make a timer
mentalcase129 Mar 20, 2013 6:14 PM (in response to Andrei1)Would you be able to tell me which part of this coded dictates the start time? So like if I wanted to change it a higher number than 2 minutes?
-
4. Re: Make a timer
Andrei1 Mar 21, 2013 4:28 AM (in response to mentalcase129)The line
date = new Date(1000 * 120);
sets it to 2 minutes.



