A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Count up timer

  1. #1
    Junior Member
    Join Date
    Jan 2007
    Posts
    7

    [F8] Count up timer

    Hello,

    I am trying to find a way to script a count up timer. The timer would have seconds(no milliseconds), minutes, and hour fields. This timer will be implemented into a game to show how long the person has been playing it. I would like it to start as soon as the .swf is opened.

    Thank you for any insight!

  2. #2
    Robot Master the--flash's Avatar
    Join Date
    Jul 2005
    Location
    The year 20XX...
    Posts
    132
    Something like this, mayhaps? I did check to see if the hour thing actually works, just to be sure, and it does. I cranked it up to 120 FPS and waited a few minutes.

    EDIT: I still had it on 120 FPS, fixed it now.
    Attached Files Attached Files
    Last edited by the--flash; 05-04-2007 at 04:11 PM.

  3. #3
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    here's one i made, the coding is a bit more current, just add this to the first frame of a new movie to see it in action. If you have any problems getting it working within your game lemme know and I'll help make sense of it good luck!

    Code:
    var seconds:Number = 1;
    var minutes:Number = 0;
    var hours:Number = 0;
    
    this.createTextField("timer_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
    function updateTimer():Void {
    	 seconds++;
    	 if(seconds > 59){
    		 minutes++;
    		 seconds = 0;
    	 }
    	 if(minutes > 59){
    		 hours++;
    		 minutes = 0;
    	 }
    	 timer_txt.text = hours + ":" + minutes + ":" + seconds;
    }
    
    var intervalID:Number = setInterval(updateTimer, 1000);
    Evolve Designs Interactive Media
    the natural selection

  4. #4
    Junior Member
    Join Date
    Jan 2007
    Posts
    7
    Thank You!

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