A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help with Countdown Timer

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    37

    Need help with Countdown Timer

    Hey everyone,

    So I have a game that causes you to lose if you don't complete a task in a certain amount of time.

    I tried a few things, and looked at some tutorials but couldn't find anything.

    All I want is for the timer to cause the player to be sent to a lose frame.

    Im using AS2 in Flash CS5

    Please help as soon as possible!

    Thanks!

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    stop();
    
    var intID;
    var endTime = getTimer() + (3 * 1000);
    
    makeTime();
    
    function updateTimer() {
    	var t = endTime - getTimer();
    	if (t > 0) {
    		makeTime();
    		showTime(t);
    	} else {
    		stopTimer();
    		showTime(0);
    		trace("lost");
    		//gotoAndStop("lost");
    	}
    }
    
    function makeTime() {
    	clearInterval(intID);
    	intID = setInterval(updateTimer, 100);
    }
    
    function stopTimer() {
    	clearInterval(intID);
    }
    
    function showTime(t) {
    	dispTime.text = (t / 1000) >> 0;
    }
    
    function gameWon() {
    	stopTimer();
    	trace("won");
    	//gotoAndStop("won")
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center