Question

I followed this tutorial to check whether the swf exists on the remote server. Here is my code:

var url = 'http://' + layer_path;
var flashvars = {};
var params = { scale: "exactFit", wmode: "transparent" , allowscriptaccess: "always" };
var attributes = {class:'flash' ,name: swf_id};
var callback = function(e){
    if (hidden) $('#'+conteiner_id).hide();
    window.setTimeout(function(){

        if (e.ref.PercentLoaded() == 0) {
            // File does not exists
        }
    },1000);
};
swfobject.embedSWF(url, swf_id, "100%", "100%", "9.0.0","expressInstall.swf", flashvars, params, attributes,callback);

The swf is inserted to a div with the is swf_id, which resides in a div with id conteiner_id.

The code works great, except when the hide parameter is set to true, and the parent div is hidden. Then, I get the following error message:

Uncaught TypeError: Object #<HTMLObjectElement> has no method 'PercentLoaded' 

How can I achieve this?

Was it helpful?

Solution

Some browsers (like Firefox) have performance optimizations that defer the loading of Flash plugins that are not visible. There is no way around it other than making sure they are at least partially visible.

A popular work-around is to set their size to be very small (only a few pixels) and make sure they are on-screen and then once they load, you can move them off screen or hide them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top