views:

506

answers:

3

I have a small flash file that just loads and shows one image scaled to fit inside the content area. We use these with a javascript gallery so we have several instances on one html page (embedded with swfObject) I've been using MovieClipLoader to load the jpgs but it no longer works.

We updated the server and as far as I know only relevant thing that has changed is cache related. Previously all images and swfs were always reloaded. Now they should be loaded from cache.

I can see from firebug that the swf is actually loading the jpg it just doesn't display anything. This happens on many browser/os/flash plugin combinations. Sometimes some of the images show, sometimes none.

The code inside moviecliploader event handlers (onloadinit, onloaderror) is never run.

Any ideas on how to get this working would be appreciated.

A: 

I've had troubles in the past when using multiple instances of MovieClipLoader. Similar to you, some of the loaders seemed to timeout, never displaying the image they were supposed to load. I was told this is due to HTTP simultaneous thread limitations, supposedly two downloads at a time(but never got confirmation on that).

This is especially true if you're using multiple swf files on the page, rather than one main flash that loads them all.

I had resolved this by creating a simple queuing system in flash, where a maximum of two movieClipLoaders would be loading at the same time. Whenever one finished, it triggered the next download, and so on until all downloads were processed. That worked very well.

sthg
A: 

I can not use a single main flash. We need to have separate flash loaders for each image. As far as I know it's not possible to create a queuing system that handles from 1 to N flash loaders.

After a lot of testing I found out that the actions in frame 1 are not run at all when the flash loads so this does not seem to be a MovieClipLoader bug after all. I added a simple code to draw a blue line on stage to the first frame and the line does not appear at all when load fails.

Gene
A: 

I found a solution.

Turns out the problem had something to do with cache but nothing to do with the MovieClipLoader.

I was scaling the loaded image based on Stage.width and Stage.height. What I found out was that flash will sometimes give a width and height of 0 for a short period of time. This may happen even if there is stuff visible on stage. previously this was not a problem since the dimensions were correct once the image loaded. Now when the images come from a cache the dimensions are sometimes 0.

the solution was to check the stage dimensions in an onEnterFrame handler and only proceed with the loading in case the dimensions are > 0

Gene