Flash SWF not initializing until visible - can I force them to initialize?

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-05-04T20:33:26Z Indexed on 2010/05/05 23:28 UTC
Read the original article Hit count: 261

I have an application that needs to render about 100 flash graphs (as well as other DOM stuff) in a series of rows that vertically extend many times beyond the current visible window - in other words, the users have to scroll down see see all the different graphs.

This application is also dynamic and when a user changes a value in the DOM (anywhere on the page) it will need to propagate that change to all the Flash graphs at the same time.

So I setup all the externalInterface callbacks and was careful to not let any JS start going until the ever-so-important "flashIsReady" call and...it worked great until I tried to update() the existing swf's with new data.

Here was the behavior: - All the swfs load (initially) in both IE/Fox = good. - Updating swfs with new content works in IE but not in Fox = not good - Updating swfs with new content works in Fox --ONLY IF-- I scrolled down to the bottom of the page, then back to the top -- BEFORE -- I triggered an update().

So then I started tracing out each time a swf called the JS to say "flash is ready" and I realized, Firfox only renders swfs as they become visible. And To be honest - that's fine and actually, I am pretty sure that IE does this too. But the problem is that not only does Firefox not initialize the swf, Firefox doesn't even acknowledge the swf exists (expect for after onload) if it has not yet been visible.

And the proof is that you get JS errors saying:

"[FlashDOMID].FlashMethod is not a function".

However, scroll down a little, wait until its visible and suddenly the trace starts lighting up

"Flash Ready", "Flash Ready", "Flash Ready" and once they are all ready, everything works fine.

Someone told me that FF does not init swf's until visible - can I force it? I can post code if you need...but its pretty heavy (hard to strip out the relevant from the rest) and I would like to avoid it (for your sakes) if possible.

The question is simple - have you had this happen and if so, did you find a solution? Does anyone now how to force a not-yet-visible swf to initialize? Thanks guys.

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about jQuery