The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Need help creating a simple timer/counter

  1. #1

    Need help creating a simple timer/counter


    I am currently making a simple timer/counter in Flash and have run into a little problem. I have a very simple set-up: 1 frame and two dynamic text-boxes. Also two layers (one for the AS and one for the text-boxes).
    I want the text-boxes to start out with their own number and count up from there. I've got the counting right, but right now they both start at zero. I want text-box 1 to start at "4 500 000" and text-box 2 to start at "2 600 000 000" and go from there.

    I am attaching the .fla - any help appreciated!

    Flash file:
    It's been a while ... how is everyone?

  2. #2
    This should do the trick:

    day_txt.text = "4 500 000";
    const dayStart:uint = 4500000
    var daycounter:Timer = new Timer(100,0);
    daycounter.addEventListener(TimerEvent.TIMER, dayCounter);
    function dayCounter(event:TimerEvent):void {
    	day_txt.text = (daycounter.currentCount + dayStart).toString().public::['toSpaceyFormat']()
    String.prototype.toSpaceyFormat = function():String {
    	return this.split('').reverse().map(function(e, i, a):* { return i % 3 ? e : e + ' ' }).reverse().join('')
    year_txt.text = "2 600 000 000";
    const yearStart:uint = 2600000000;
    var yearcounter:Timer = new Timer(1,0);
    yearcounter.addEventListener(TimerEvent.TIMER, yearCounter);
    function yearCounter(event:TimerEvent):void {
    	year_txt.text = (yearcounter.currentCount + yearStart).toString().public::['toSpaceyFormat']()
    Who were you, Krilnon, and how did you know so much about AS4?
    The historian sighed as she gazed up at the sky and saw not stars. A story.

  3. #3
    Thank you so much, Krilnon! I was in a bit of a deadline-squeeze here!
    It's been a while ... how is everyone?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012