简体   繁体   中英

Actionscript Flex getTimer() maximum

Documentation on the flex getTimer() method states:

int - The number of milliseconds since the runtime was initialized (while processing ActionScript 2.0), or since the virtual machine started (while processing ActionScript 3.0). If the runtime starts playing one SWF file, and another SWF file is loaded later, the return value is relative to when the first SWF file was loaded.

The maximum value for an int is: 2,147,483,647 which is a bit less than 25 days. If someone were to leave the flash application running for an extended period of time, does anyone know what happens when this method reaches the maximum value for int? Does it reset to zero?

I don't know the answer for sure, but I would assume the number would roll over. However, if you're concerned about the roll over, you might want to look at the Timer class, or just use a good ol' timestamp with new Date().getTime() and then doing a comparison between the times.

When int reaches it maximum value 2147483647 and on adding 1 , it should resets to its maximum -ve value -2147483648 and it's iterative in nature, so function should not fails

EDIT Code sample is added

private function intcheck():void
{
    var a:int = 2147483647;
    var b:int = 1;
    var c:int = a+b;

    Alert.show(c.toString());
}

Hopes that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM