topic as tree
 
 
Modifiying Script Timeout Length
FROM: compiled | TO: all | DATE: 02/13/2004 09:11:56AM | PERMALINKS: community / blog

Today on FlashCoders someone was asking about dealing with looping through large arrays and if it's possible to modify the script timeout length. I happened to have the swf 7 spec opened at the time and noticed the ScriptLimits tag. In short.. the spec has this to say "The ScriptLimits tag includes two fields which can be used to override the default settings for maximum recursion depth and ActionScript time-out..."

This evening I decided to give it a try. I nabbed the latest version of Flasm and sure enough ScriptLimits was right there under the what's new blurb.

I wrote a script to loop from 0 to 5000000, sure to give me a timeout warning... decompiled it into a Flasm project, opened the project in notepad, added the ScriptLimits tag (see code below)... and viola! I successfully increased the timeout to 140 seconds and never got the timeout warning. Scary, I know.

It was a fun exercise in what you can do with swf bytecode but I would never recommend actually using this in a production environment. If you have a huge chunk of data to parse or some crazy algorithm causing you timeouts you should probably rethink the way you're dealing with it. Flash just isn't made for that kind of stuff. And letting the player sit there unresponsive for an extended period of time is sketchy, at best. So break those loops up, might be not be as elegant but at least your users won't spaz out when the player sits there lifelessly.

..

Flasm Script (note: the -- is a wrap in the line)

movie 'loop.swf' compressed // flash 7, total --      
frames: 1, frame rate: 31 fps, 550x400 px      
scriptLimits recursion 256 timeout 140      
  frame 0      
    constants 'i'        
    push 'i', 0.0      
    varEquals      
   label1:      
    push 'i'      
    getVariable      
    push 5000000      
    lessThan      
    not      
    branchIfTrue label2      
    push 'i', 'i'      
    getVariable      
    increment      
    setVariable      
    branch label1      
   label2:      
  end // of frame 0      
end      



edited by compiled on 03/23/2004 at 06:22AM

REFERENCE:
thread map
compiled