views:

1996

answers:

4

I have an application written in flash (actually it is written in haXe and run under SHWX but it doesn't matter here). I have a pretty complex task that consumes a lot of CPU power and sometimes executes for more that 15 seconds. If that happens, I've got an error saying 'A script has executed for longer than the default timeout period of 15 seconds.' and everything crashes.

I know I can use continuations to stop this from happening but is there a way to extend that 'default timeout period'? It's a developer tool, responsivnes doesn't really matter.

+1  A: 

I'm not sure if there is something more native to get this done, but there seems to be a command that hacks the SWF to add a ScriptLimits tag to extend the timeout period.

Swaroop C H
A: 

I suggest breaking your function into smaller chunks and spreading them over multiple frames. This way you can display an progress animation and the Flash application won't become unresponsive. So for example if you have to loop over 1000 items, you do 100 in one frame, then another hundred in the next frame, etc, until you have processed them all. I wouldn't recommend hacking your swf.

Iain
+1  A: 

Another way is to link a swfmill-based swf via -swf-lib switch and set this ScriptLimits tag there, haxe will re-use it then.

Michael Pliskin
+1  A: 

in CS3+ you simply set the "Script time limit" property of the swf at publish time - it's in the flash tab of the publish settings