6 Replies Latest reply on Oct 26, 2011 3:02 PM by Flex harUI

    How to detect if my SWF was successfully retrieved or not?

    JoshBeall Level 1

      Hi All,

       

      We have a full-viewport Flex app that is integral to our business.  "Full-viewport" means that there is nothing else on the page--the Flex app uses the entire viewport.

       

      The app was developed in Flash Builder 4, and we're using the default HTML/JavaScript that Flash Builder provides for the host page that SWF lives on.  This is using SWFObject.

       

      From time to time, we get calls from customers who try to use our Flex app and instead get a completely blank page. The only way I can replicate this myself is if I do something to prevent the SWF from downloading.  E.g., if I change the name of the SWF so that SWFObject gets a 404.

       

      The best guess I can give as to why customer's might get this behavior is that they've got some kind of security software that is blocking SWFs, or at least blocking this particular SWF.

       

      I am wondering how I can tell, in JavaScript, whether or not the SWF was successfully loaded by SWFObject.  I would like to display a notice to the user saying that the Flash file failed to download, and giving them some suggestions on how to get it to download (e.g., check security software settings, unblock Flash, etc.).  I would then also send a notification to myself notifying me that we had a "blank screen" incident, along with some debugging information about the client's browser.

       

      If there was a way for me to know in JavaScript the results of the SWFObject embed attempt, I think I could do this.  Suggestions?

       

        -Josh

        • 1. Re: How to detect if my SWF was successfully retrieved or not?
          Flex harUI Adobe Employee

          How about if you write your app to use ExternalInterface to call a javascript function?  If that function doesn’t get called by a certain time, then assume the load failed.

          • 2. Re: How to detect if my SWF was successfully retrieved or not?
            JoshBeall Level 1

            I was thinking about doing that, but I didn't know if there was a better way--maybe SWFObject has a "failed" event I can listen for?  But I haven't been able to find anything like that yet.

            • 3. Re: How to detect if my SWF was successfully retrieved or not?
              Flex harUI Adobe Employee

              There is code in the history.js that attempts to talk to the player that might be helpful.  Also, there is a separate email forum just for SWFObject at swfobject@googlegroups.com.  They seem to be pretty responsive.

               

              That reminds me, if you have custom loading and sizing logic, there is a window of time where SWFObject causes the stage to report a width and height of 0.  We have workarounds for that in the SDK, but if you’re code is tripping over that, you could end up sizing the content to 0,0.

              • 4. Re: How to detect if my SWF was successfully retrieved or not?
                JoshBeall Level 1

                We're not doing anything with custom loading and sizing logic, unless the default Flash Builder 4 HTML host file does custom loading and sizing.  We haven't changed anything.

                 

                SWFObject has an callback function to see if the <object> tag was written onto the page properly, but it doesn't have any way of knowing if the SWF itself was successfully downloaded.  Search here for callbackFn to find the info on this.

                 

                I hear that CheckPlayer does have a way of determining this... I'm looking into that.

                 

                  -Josh

                • 5. Re: How to detect if my SWF was successfully retrieved or not?
                  JoshBeall Level 1

                  Well, an issue I've run into is that since my Flex app is full-viewport, there's nowhere for me to display an HTML message.  The Flash move displays on top of everything as usual.

                   

                  So, even if I were able to work out a way to determine if the SWF failed to load, I wouldn't be able to display it.  But I suppose I could redirect the user to another page where I gave them some useful troubleshooting information.

                   

                  Any any rate, this got me thinking--why is Flash movie displaying on top of everything--even if I delete the SWF file, so there is no Flash movie to download.  Hmm... right click on the big white viewport, and you get "Movie not loaded" in the Flash Player context menu.

                   

                  So, even though the Flash move is not loaded, the Flash Player did start.  Which leads me to ask... is there a way to interrogate the Flash Player directly, and see if it loaded the movie or not?

                   

                  Clearly the Flash Player is aware that the SWF failed to download.  It tells me right in the context menu, "movie not loaded."  The question is, can I programmatically interrogate the Flash Player from within JavaScript?

                   

                  Suggestions?

                   

                  p.s., I'm aware that I could change the WMODE to transparent to try and let my HTML message show through the SWF, but I want to avoid doing that at all costs :-) I've had too many problems in the past with subtle (and frustrating) errors when I change WMODE away from the default value of Window.

                  • 6. Re: How to detect if my SWF was successfully retrieved or not?
                    Flex harUI Adobe Employee

                    That’s a good point, and brings you full-circle back to ExternalInterface.  If you are certain that the player is running, then you go back to the option of using ExternalInterface to handshake to the external app.  If no callback exists, then your app didn’t run far enough to register the callback so you can consider that a failure.

                     

                    I’ve never played with the HTML tags themselves, but I would wonder what would happen if you set the div containing the player to a zero width/height or made it hidden and then if it is up, make the div containing the HTML message hidden.