RESEARCH AND FINDINGS ABOUT THE LOADING OF EXTERNAL MOVIES IN FLASH

------------------------------------------------------
TWO STAGES (FIRST OPEN, THEN LOAD)

There are two distinct stages of loading when loading an external movie: OPENING and LOADING

  • The first stage is OPENING, where the movie being opened, or more accurately, the host clip into which a movie is being loaded, returns a totalBytes() of -1(online mode only). This opening period takes between .4 seconds and 6 seconds generally, but it is NOT proportionate to movie size (ie. it has to do with user connection, latency, etc.) it's actually faster on a 56K modem than a 400Kb DirecWay dial-return satellite connection with very high latency.
  • The second stage is LOADING, when the movie clip has opened, the totalBytes has been set correctly, but the movie has not downloaded completely. This is important to realize, because smaller clips (<5 kB) will take 1 or 2 seconds to open, and by the time they have opened, they are already totally loaded. Of course for larger loaded movies, they will open first, then finish loading.

------------------------------------------------------
WHAT IF THE EXTERNAL CLIP IS NOT THERE?

As far as I can tell, there are NO indications from within flash that a loaded movie path is not valid. I have tried every conceivable property, and none work. The onClipEvent(data/load) assigned to the container (host) movie clip is supposed to work for this sort of thing, but it does not fire as I would expect. Rather, it fired in irregular intervals during the download, but not at the key points when the movie finished opening or loading.

The only reliable way to ensure an invalid movie clip is skipped, is to start a timer when the loadMovie is invoked, and to set a timeout period, after which the movie is skipped if it is not OPENED. Since there seems to be an absolute ceiling of about 6-8 seconds for a clip to open, regardless of size, I have set my timeout to 10 seconds and found that it works well. What I mean here, is that if after 10 seconds the movie has not OPENED, it is skipped. If the movie HAS OPENED, but is still LOADING at the 10 second cut-off, it is NOT skipped, but rather it continues loading. After testing this exhaustively, I found that the open time CAN EXCEED 10 SECONDS on a clip that's actually there, as a result of a trashed request, ie. for some reason the request to open is not registered on the server. (this happened to me when I was doing a big upload in the background while testing my movie. I added logic to the RCM Smart Loader to re-try each clip once for 3 seconds before it is skipped. This seems to handle trashed requests effectively.

To further complicate this matter, testing external movie Loading OFFLINE is totaly unreliable. it gives erronious readouts for totalBytes and it actually results in different _url properties appearing for levels / host clips you are loading into, than the same script will give in an online environment. For example, in an offline mode, a movie that is not loaded successfully will cause the _url property of it's parent clip to revert to the same _url as the main movie, after the error occurs. In an online mode this never happens. There are several other idiosyncracies that cause problems like this. To account for this, the RCM Smart Loader detects for the "file://" prefix on loaded files offline and applies different logic to them than online files with the "http://" prefix.


------------------------------------------------------
MULTI STREAM vs. SINGLE STREAM

On low speed connections, it can take more than ten seconds for a valid movie to open, IF the main movie is not FULLY LOADED. This means that you must be sure your _root is fully loaded (_root.getLoadedBytes() == _root.getTotalBytes()), before starting additional movie downloads. Otherwise, you cause two simultaneous download streams, which may cause unpredictable results. On high speed connections, dual streams are not a serious issue, and can actually result in less overall load time.

------------------------------------------------------
CACHE ISSUES

Loaded movie clips (and all flash files for that matter) will remain in the browser cache until they are cleared by choosing Internet Options>Delete Files, while your browser is on a Different Page than the one the movies load in. Ie. if you delete files, while you are still on the page, it doies not clear the files you are looking at) Alternatively, you can pass a random querystring across "myFile.swf?id=123345"... which will force the server to fetch the file each time. But since you are using the browser cache to pre-load files, I prefer the former method.

 

Ryan Cooper

------------------------------------------------------
CONTACT [email protected] to report bugs, problems, and feature requests.

RCM Smart Loader ©2002 Ryan Cooper Multimedia, All Rights Reserved