I wrote CheckPlayer, and I have it used in a number of applications, where EI availability testing was an important factor. That's why I built that feature in fact, for this exact reason.
The caveat to the generic code in CheckPlayer is that your SWF has to have some sort of function exposed on it that you can call, without any parameters, and that not affect the SWF's behavior in a bad or irreversible way. For instance, if you have a MP3 player, and it has a "StopSong()" function on it, it shouldn't be a problem to call "StopSong()" over and over during loading of the SWF because once it succeeds the first time (and an actual call to StopSong goes through to the SWF), generally speaking that action didn't require any parameters, and asking the player to stop a song while it's already stopped shouldn't be a problem. By the same token, if you actually are wanting your mp3 player to start playing as soon as possible, via a call to "StartSong()", then you are essentially needing the same mechanism, to basically keep trying to call the function until a JS error doesn't occur. Where it wouldn't work is if all your functions on your SWF require parameters, and throw errors (or cause bad behavior of the SWF) if no parameters are sent. In this case, you'd not want to use the generic code that CheckPlayer provides, but instead write your own similar logic but with an exact function call (and parameters) customized to whatever your situation is. If you need some help with CheckPlayer, I suggest you post to the flensed list or in the forums. We'll be happy to help you over there. --Kyle -------------------------------------------------- From: "aldana" <[email protected]> Sent: Tuesday, March 03, 2009 12:07 PM To: "SWFObject" <[email protected]> Subject: Re: problems integration swfobject 2.1 and jquery (document.ready) > > Yes this loading order is a nightmare. > > Has somebody made work checkplayer lib with a flash app using > ExternalInterface? Does it support it? > > On 21 Jan., 18:00, "Getify Solutions, Inc." <[email protected]> wrote: >> Yes, in my testing, I found the window-load type events (and dom-ready >> events as well) unreliable in determining if the EI was ready or not. If >> you >> are not having those troubles, then I wouldn't worry about it. But it is >> something to be aware of, that IE does have some delay in getting those >> initialized. >> >> --Kyle >> >> -------------------------------------------------- >> From: "aldana" <[email protected]> >> Sent: Wednesday, January 21, 2009 8:51 AM >> To: "SWFObject" <[email protected]> >> Subject: Re: problems integration swfobject 2.1 and jquery >> (document.ready) >> >> >> >> > cool, thanks. >> >> > I got the window.onload callback in place now, which works fine >> > (anyway the item i need swfobject for is at the bottom of the page). >> > so maybe I'll stick with this. I highly appreciate your little lib, >> > but including it would even increase the javascript lib complexity we >> > already have, which I want to avoid. >> >> > what does speak against accessing .swf through window.onload callback? >> > will it be non-deterministic in terms of accessibility of the .swf >> > (some browsers load faster/slower, page load time)? >> >> > On 21 Jan., 14:16, "Getify Solutions, Inc." <[email protected]> wrote: >> >> Bobby's code below is a good start, but it's not robust enough >> >> according >> >> to >> >> what I've found in testing. For instance, in IE, there's actually a >> >> split >> >> second where the function is "defined" on the flash swf dom object, >> >> but >> >> it's >> >> not actually got anything in it yet (like it's an empty function >> >> value). >> >> There are several complications which ensue. >> >> >> As an alternative to rolling your own code for waiting for >> >> ExternalInterface >> >> to be ready, there's a library that I wrote and maintain called >> >> CheckPlayerhttp://checkplayer.flensed.com/which wraps around SWFObject >> >> and adds some >> >> additional "advanced" functionality, including in this case, >> >> ExternalInterface availability checking. >> >> >> Basically, the strategy is to give the library a specific function >> >> name >> >> to >> >> try to call on the swf (**caveat), which it will loop trying to do >> >> until >> >> the >> >> try/catch around it *doesn't* fail (in which case you now know for >> >> sure >> >> the >> >> function is ready!). Now that the readiness is detected, it calls an a >> >> callback function you define, which notifies the rest of your code >> >> that >> >> the >> >> SWF is fully ready to go. >> >> >> It's not the prettiest solution, but it was what I found to be most >> >> reliable >> >> in terms of full cross-browser testability. >> >> >> My suggestion is, rather than trying to figure out these frustrations >> >> for >> >> yourself as I did, you might consider using CheckPlayer. Otherwise, >> >> you >> >> can >> >> look to trying to duplicate the logic I implemented for your own code. >> >> >> --Kyle >> >> >> **caveat: The only "downside" really (which is usually not a problem) >> >> is >> >> that you have to have some function defined which is ok to be called >> >> just >> >> plain, without any parameters, who's successful calling will not >> >> create a >> >> problem with the state of your SWF (since it'll be guaranteed to be >> >> called >> >> once successfully before the rest of your code continues). So, on my >> >> SWF's, >> >> I usually have some sort of simple "Reset" or "Init" function, which >> >> doesn't >> >> really even have to do much, but is a valid function I can call on the >> >> SWF >> >> without using any parameters, and once it's ready, I know the rest of >> >> my >> >> important functions are also ready. >> >> >> -------------------------------------------------- >> >> From: "Bobby" <[email protected]> >> >> Sent: Wednesday, January 21, 2009 6:58 AM >> >> To: "SWFObject" <[email protected]> >> >> Subject: Re: problems integration swfobject 2.1 and jquery >> >> (document.ready) >> >> >> > Your SWF and External Interface functionality will need some time to >> >> > initialize, so calling it directly when the DOM is loaded is too >> >> > quick. >> >> >> > You'd better only call it as soon as it is available, e.g.: >> >> > var obj = document.getElementById("flashCookie"); >> >> > (function() { >> >> > if (obj && typeof obj.JStoASviaExternalInterface != "undefined") { >> >> > obj.JStoASviaExternalInterface(); >> >> > } >> >> > else { >> >> > setTimeout(arguments.callee, 10); >> >> > } >> >> > })(); > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/swfobject?hl=en -~----------~----~----~----~------~----~------~--~---
