Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8304829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:56:44+00:00 2026-06-08T17:56:44+00:00

Something that has always puzzled me, and still does to this day, is why

  • 0

Something that has always puzzled me, and still does to this day, is why can the Timer class in AS3 not update fast enough for the lower millisecond numbers?

I seem to recall reading that Flash is capable of pushing an update to the Timer once every 20 milliseconds at the maximum (recommended) – The timer that I have created for a recent game updates every 50 milliseconds, but even that is struggling. Locally it works fine, in an online environment, it does not.

Is there something specific I’m doing wrong here, or is Flash just really not capable of updating fast enough in an online environment to do a two decimal place number of a second?

Again, this works fine locally.

My code for the timer is here:

package src.gameShared {

import flash.display.Sprite;
import flash.utils.Timer;
import flash.events.TimerEvent;
import src.main;


public class timer extends Sprite {

    private var _updateAmount:int = 50;                     // MUST give a whole number if divided by 1000 and less than 100. Recommended above 20. Gives 25, 40 or 50.
    private var _timer:Timer = new Timer(_updateAmount,0);
    private var _count:int = new int();

    public function startTimer():void{
        _timer.addEventListener(TimerEvent.TIMER, updateText, false, 0, true);
        _timer.start();
    }

    public function stopTimer():void{
        _timer.stop();
        // Add to score
    }

    private function updateText(e:TimerEvent):void{
        _count++
        dtf_txt.text = returnTime();
    }

    // The below will display double minutes, double seconds and double milliseconds. Most math is based around the double milliseconds.
    public function returnTime(_score:Boolean = false){
        /*
        ** Minutes takes _count and divides it by (1000/50) = 20 (_updateAmount being 50), to give the value of 1 per second. If _count is 20, this has run 20 times and thus 1000 miliseconds have passed
        ** So the int can be set to 1. Minutes then checks to see if there is 60 of them (60 seconds).
        ** Seconds does the same, except it "caps" at 60 before resetting
        */
        var _division:int = (1000/_updateAmount)

        var minutes:int = Math.floor(_count /_division / 60);
        // Second is 1000 miliseconds
        var seconds:int = Math.floor(_count /_division) % 60;
        var milseconds:int = new int();

        /* After how many ticks is it a second. So at 50, 20 ticks would be 100 so 1 second, but _count would only show 20. So we *5 to get 100.
        ** 100 = max num we want, divided by (1000 (1sec) divided by _updateAmount)
        ** 100/(1000/50) = 5. 5*20 (number of ticks at 50milli per sec) = 100 = what we want
        */
        var _getMil:Number = 100/(1000/_updateAmount)   // 5 (20 lots of _updateAmount per second, we want an update on every tick. We do *5 as 20 updates fits into 100 that way)
        // How many updates to fit into 1000 (1 sec), then divide it by 10 as we want a single digit result
        var _getSmallMil:Number = (1000/_updateAmount)/10   // 2 (20 lots of _updateAmount per second, we only want an update every 2nd for the whole number, so we half _count)

        _score == false ? milseconds = Math.floor(_count*_getMil) % 100 : milseconds = Math.floor(_count/_getSmallMil) % 10;
        // Easier to read code that does the same thing but isn't dynamic:
        // _score == false ? milseconds = Math.floor(_count*5) % 100 : milseconds = Math.floor(_count/2) % 10;

        var secString:String = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
        var minString:String = (minutes < 10) ? ("0" + String(minutes)) : String(minutes);

        if(_score){
            var milString:String = String(milseconds);
            if(minutes >= 1){
                var _holder:int = int(secString);
                _holder = _holder + (minutes*60);
                secString = String(_holder);
            }
            return secString+"."+milString;
        }
        else{
            var milString:String = (milseconds < 10) ? ("0" + String(milseconds)) : String(milseconds);
            return minString+":"+secString+":"+milString;
        }

    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:56:45+00:00Added an answer on June 8, 2026 at 5:56 pm

    Timers are optimal for non-animated content; however, as a visual runtime it is logical not to compute beyond the frame rate.

    Targeting 60 frames per second is a realistic ceiling.

    There are great articles on the Flash elastic racetrack.

    elastic-racetrack

    marshal slice

    marshal slice

    References

    • Adobe runtime code execution fundamentals
    • Updated elastic racetrack
    • Flash Player Mental Model – The Elastic Racetrack
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is something that has always bothered me about PHP and I have never
This is something that has always bothered me. Wouldnt it make more sense to
This is something which has always puzzled me. If I want to make a
Not a massive problem but something that has been bugging the life out of
I am trying to update the database to show that something has been uploaded.
I've been using JSF for a while but there's something that has always confused
Something that has always bugged me is how unpredictable the setTimeout() method in Javascript
Something that has always bothered me is doing more than one loop to manipulate
I'm not sure if this is a proper programming question, but it's something that
So this has been something that has been bugging me for a while. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.