Jump to content
unplugged_web

5 Minute Timer

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 by Abarrow

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...