unplugged_web 2 Posted October 30, 2009 Report 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 Quote Link to post Share on other sites
Abarrow 0 Posted November 15, 2009 Report Share Posted November 15, 2009 (edited) 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; }} Edited November 15, 2009 by Abarrow Quote Link to post Share on other sites
unplugged_web 2 Posted November 16, 2009 Author Report 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.