PDA

View Full Version : How to Detect Load Status or Blocked Content


Cerin
04-16-2008, 02:14 PM
Hi,

I've noticed that some corporate firewalls block Flash content from sites like Youtube, Myspace, etc, and I'm trying to find some way if I can detect this on the client for my own Flash content. If the content failed to load, I'd want to display a help or error message, rather than just some blank space.

I've researched this pretty heavily, and while it's pretty easy to tell if Flash is installed, there doesn't seem to be any easy way to tell if Flash has loaded or had problems loading. I tried adding an onload event to the <object> and/or <embed> tags, but they're never called. The only other solution I could think of would be to write a custom SWF that loads a target SWF, and then uses ExternalInterface() to call some Javascript function that'll log any loading errors.

Does this seem practical? Are there easier ways to tell when a Flash object has failed to load, even if there's nothing wrong with the client's player?

Arodicus
04-27-2008, 12:50 AM
I'm having the same problem.

Barring ExternalInterface callbacks, the best thing I've come up with so far is checking the Object/Embed for an attribute called TotalFrames; if the movie loaded, it will have a value, if not, it will either be 0 or throw an error if you try to read it. Because of that, you need to use try/catch:


// Javascript
function DidSWFLoad(id){
try {
return document.getElementById(id).TotalFrames > 0;
} catch(e) {
return false;
}
}

var loaded = DidSWFLoad("MyMovieID")


I've not tested this extensively, however, and you also need to remember to give the movie a chance to actually load before attempting the call.