Javascript / SWFobject | Determine if a swf object exists when creating dynamic embed objects
Asked Answered
M

1

1

When I create SWF objects that are temporarly hidden in tabs, thus not fully loaded in some browsers, like FireFox, I can't seem to find way to figure out if the SWF is loaded or not, so I can communicate with it.

/* Generate SWF (onDocumentReady())*/

swfobject.embedSWF("graph.swf","line-graph-one","100%","250","8","expressInstall.swf",null,null,null,swfRegister);

/* Callback function 
 * -------------------
 * Is triggered when SWF object has done it's job, which is fine, but not a 
 *  suggestion that the SWF is actually loaded by the browser) 
 */

function swfRegister(e){
   console.log(e);
}

Here is what doesn't work. While the element exists in the DOM, it's not possible to communicate with it somehow. FireFox in this case hasn't loaded the SWF because the parent container is hidden.(display:none;)

document.getElementById('line-graph-one').reloadAll("foobar");

Resulting in: document.getElementById("map-one").reloadAll is not a function

It only works when I click the tab where the SWF has been created. So FireFox loads it.

I need a way to check if it is loaded,

Mis answered 16/9, 2010 at 12:29 Comment(0)
P
1

Perhaps a visibility check first?

var $el = $("#map-one");
if ( $el.is(':visible') ) {
  $el[0].reloadAll('foobar');
}
Preacher answered 16/9, 2010 at 12:37 Comment(2)
It doesn't work, because the element already exists in the DOM, but the actual SWF is not loaded by FireFox. (Firefox tends to load only SWF's visible on the screen). I'll edit my post.Mis
Ahh, if that's the question, you could maybe just check to see if it's visible first.Preacher

© 2022 - 2024 — McMap. All rights reserved.