unplugged_web Posted October 30, 2009 Share Posted October 30, 2009 I want to create a countdown timer that counts down five minutes (or two, or three), but only when somebody clicks a button. Then when it reaches zero the timer changes to text saying times up. I've looked on google, but all I can find it timers that allow you to count down to a particular date rahter than a set amount of time. Is this possible and how do I do it. I did read this in this forum, but wasn't sure how to actually implement it in terms of where do I put the code and how do I make it so that it will only start counting down when somebody clicks a button.Thanks Link to comment Share on other sites More sharing options...
Abarrow Posted November 15, 2009 Share Posted November 15, 2009 It's pretty easy to make a timer in as3.eg: this.miutes=5;this.message="Boom!"button.addEventListener(MouseEvent.CLICK,clickcallback);function clickcallback(e:MouseEvent) { var myTimer:Timer=new Timer(1000); this.tim=ths.minutes*60; myTimer.addEventListener(TimerEvent.TIMER, timerHandler); myTimer.start();}function timerHandler(event:TimerEvent):void { this.tim--; output.text=this.tim; if (this.tim==0) { output.text=this.message; }} Link to comment Share on other sites More sharing options...
unplugged_web Posted November 16, 2009 Author Share Posted November 16, 2009 It's pretty easy to make a timer in as3.eg:this.miutes=5;this.message="Boom!"button.addEventListener(MouseEvent.CLICK,clickcallback);function clickcallback(e:MouseEvent) { var myTimer:Timer=new Timer(1000); this.tim=ths.minutes*60; myTimer.addEventListener(TimerEvent.TIMER, timerHandler); myTimer.start();}function timerHandler(event:TimerEvent):void { this.tim--; output.text=this.tim; if (this.tim==0) { output.text=this.message; }} Brilliant thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.