setInterval function in Flash works fine with builtin flash player (testing phase) but when I use same (published) swf on standalone player it is almost 10 times slower than that. To confirm i created a simple counter without any graphics and noticed this issue.
PS: I have checked on various player versions and even on internet browsers and even on VMWare on windows 7. I tried all other options like cpu and gpu acceleration but no improvement.
My testbench:only one frame and one dynamic text field with name "te". following is the action script
var lo=0;
function f():void{
te.text=lo++;
}
setInterval(f,0);
The true answer here is that you are using setInterval
with a value of 0
. Which means that you want to do as many possible calls to the function f
in a frame as possible. But because of the nature of AS3, the frame switching is delayed so that the code inside can be executed (frame rate drop). But you never finish executing - your setInterval
keeps going forever and is busting up everything. It's like writing while (true)
loop..
So just start using it properly and you won't have any problems.
I recommend you to use flash Timer class to precise interval time, it works more efficent compared to ENTER_FRAME or setInterval
var myTimer:Timer = new Timer(1); //ms
var time = 0;
myTimer.start()
myTimer.addEventListener(TimerEvent.TIMER,timerHandle);
function timerHandle(e:TimerEvent){
txt_time.text = time.toString();
time++;
}
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.