Jump to content

5 Minute Timer


unplugged_web

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

Link to comment
Share on other sites

  • 3 weeks later...

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...