[osflash] AS2 MovieClipLoader timeout
Juan Pablo Califano
califa010.flashcoders at gmail.com
Sun Apr 27 18:04:45 PDT 2008
As far as I know, a script timeout doesn't apply to asynchronous actions
such as loading external files. My understanding is that the player divides
execution of actions in frames. The execution is blocking: it plays one
frame at a time, and it only continues with the next frame once the current
frame is completed. If a frame takes more than a certain number of seconds
to complete (30 seconds is the default, I think), it will display a timeout
alert. A typical case is an infinite loop (which is always an "error" in an
swf, given how the player works); but it could also be that you are calling
a function that just takes too long to finish. I once had a problem with a
function that layed out a table, with a lot of nested levels of movieClips
(and to be honest, it was poorly thought out, code-wise). When the number of
rows was bigger than, say, 45, the player would show the dreaded timeout
alert; but by that time, many frames were dropped, all animations were
frozen and the app was unresponsive. To solve that problem (re writting was
not an option), I "cut" that function into slices, with a setInterval. Doing
sure makes the code ugly and messy, but it works, as long as you can prevent
the function from taking too much time to run each pass. It works because
what you're doing is telling the player to make each run of the function in
a different frame, instead of running it all at once.
So, you should probably try to look for some function that takes too long to
complete (for instance, get the value of getTimer() at the first line and a
call again getTimer() before returning; substract both values and you have a
rough estimate of how long it took to execute the function). Anyway, in my
opinion, the problem is unlikely to be in the asset loading itself.
While we're on the subject, I don't think it's a good idea to alter the
default timeOut value; if some script blocks for more than 30 seconds, it's
probably a wise choice to give the user the option to knock it off.
Juan Pablo Califano
2008/4/26, David Christensen <david at endpoint.com>:
> Greetings folks,
> A little background about my project: I have a custom-written flash
> application which is loading one of a number of external SWF files
> depending on certain form parameters in the HTML. The application is
> completely written in ActionScript 2.0 using mtasc (targeting Flash
> 8). The external files are created using swfmill and consist of a
> number of image files gathered together into a single movie, with
> each image on a frame. Each of the auxiliary files can range between
> 2-4MB, depending on the number of images in the file.
> My original approach was to try to do a createEmptyMovieClip() and
> then manually load the page images incrementally during the app
> initialization phase, essentially reproducing what the swfmill
> preprocessing code is doing, however I was not able to get this to
> work successfully. Right now, the application depends on the fact
> that there is a single movie clip with each frame being an image, and
> changing this to use incrementally-loaded images each in their own
> instance/layer would be too work-intensive.
> The application works great, I use a MovieClipLoader to download the
> remote SWF; however intermittently I get an error about the document
> loading slowly, and Flash Player asks if I would like to terminate
> the execution. From my research online, it appears that this can be
> due to the loading of the external file taking more than a predefined
> timeout (30 seconds IIRC). I feel like I've seen files which will
> take longer to load and execute, so I believe there must be a way
> around this issue.
> A couple questions:
> 1) is there a way to increase the timeout value in Flash 8/9?
> 2) lacking that, is there a way to dynamically add/create frames in a
> movie clip populated with remote images?
> 3) any suggestions for general loading tuning or other ways to
> approach this problem?
> David Christensen
> End Point Corporation
> david at endpoint.com
> osflash mailing list
> osflash at osflash.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the osflash