tags:

views:

45

answers:

2

Hey guys,

I have a page with an some normal javascript, a swf file and some jquery.

I'm running my jquery code inside the $(document).ready(function() {}) function. But the code is being run before the Flex component (the swf file) has finished loading. Is there something I'm doing wrong? Thanks for reading!

+4  A: 

The whole point of the "ready" event is to run before elements like images and Flash load. If you don't like that, use the "load" event instead.

$(document).load(function() { ... });

Another approach would be to try and attach a "load" handler to your flex object directly, but I'm not personally sure that'd work properly, and it might be a race condition for the "ready" handler to get the "load" handler set before the content actually does load.

Pointy
+3  A: 

Try using the load event instead.

The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

Andy E