PDA

View Full Version : Flash crashes


creez
01-27-2009, 08:43 PM
i am experiencing this automatic flash crash:

if i run this code on frame 1 everything is ok(this is a simple function that scale a clip):

function one(){
clip.scaleX+=.01
clip.scaleY+=.01
var _timer=setTimeout(one,1)
trace(_timer)
if (_timer==135){
clearTimeout(_timer)
}

}
one()

if i make a keyframe at frame 15 for example and cut and paste this code , flash will crash, anyone have an idea why?

senocular
01-27-2009, 08:51 PM
Its because you're creating a bazillion setTimeouts that loop and loop and loop and eventually you crash.

creez
01-27-2009, 08:57 PM
it does not crash if it's on frame 1, the setTimeout does not loop forever imo as i added a cleartimeout and traced its return value to be sure it stops. :confused:

senocular
01-27-2009, 09:07 PM
it loops because the timeline loops and everytime you go over that frame, it will re-run that script - and likely before all your existing timeouts have completed. It will keep building up and kill ya. (if you only have one frame, there is no looping)

creez
01-27-2009, 09:37 PM
okay now i see, thank you.