views:

141

answers:

3

I have a strange flash player problem which seems to be most apparent in FireFox (3.0 and 3.5, on PC).

Visit the page: http://prnewswire.com/container/tgifridays/tgifridayssocialmedianewsrelease-woody-jackdaniels/

On the initial page load, you should see a flash video player, with a paused video,and when you mouse-over the video you should see some video controls.

Now go into your address bar, and press enter at the end of the address bar to "reload" the page. Now the flash player will only show the scrollbar of the player. It does not completely load.

If you press the refresh button of the browser, you can get the whole thing to load correctly. But again if you press the "enter" key inside the address bar, it will go back to only loading the scrollbar.

I assume the problems come from the browser loading a cached version of the player versus a new version of the player. But what is the difference?

The player is pretty dynamic - The document class loads flashvars which tell it the path to load an XML file, and the XML file loads the thumbnails and videos. An instance Player() class is added to the stage (which is just the video window and video controls), and then the document class sends it a video to load and play.

I'm pretty sure this has something to do with timing. The cached file is probably loading too fast for something? But for what, I have no clue.

I can email code if you give me your email address

A: 

If you want the XML to never cache (with dynamic xml, this is probably a good idea) then use something like this

Joel Hooks
I think fenomas is right that she should remove the contention issues instead of relying on a particular load order.
James Fassett
Thanks Joel - we have already implemented this one so the XML file is never cached
Kim L
+1  A: 

It's hard to say without code, but my guess is that you're right and it's a timing issue - perhaps that one of the events you're processing on needs to be replaced with a different event that occurs later. For example, if you were accidentally trying to read the XML data in a PROGRESS event, it would probably succeed and fail unpredictably, though it's probably not quite that simple.

My advice would be to add some debug information to the file (like a text field on top of the content) and trace out messages in all the event handlers you use to control the initialization flow. That is, where you read the flashvars, and where you process the XML, etc. Figure out which stage it's breaking at, and investigate whether the event you're listening to could be replaced with a more appropriate event.

Another thing to try would be to add some try..catch statements with similar debug messages. Though if you're testing with the debug player you ought to see error messages for any uncaught exceptions.

fenomas
I second this. To see the traces for a Flash Player running in the browser have a look at this blog: http://fatlinesofcode.philipandrews.org/2009/03/28/actionscript-debugging-within-the-browser/
James Fassett
I have installed the flash player 10 debugger version, and I've been able to successfully get traces to output in the logs...it seems like when I add traces everywhere, it solves the original timing issue. So I'm still playing with trace statements everywhere to try to figure it out...it's a long slow process for me!
Kim L
A: 

So here is what happened...

I was using a preloader in AS3 to determine when the swf itself was loaded. I had this as the first line in the constuctor of my document class:

this.loaderInfo.addEventListener (Event.COMPLETE, initPlayer);

For some reason when you load the swf from the cache in firefox on a PC, that Event.COMPLETE never fires, maybe because the file is already considered loaded at that point? (It still fires in other browsers, so I'm not sure if this is a bug or not). So when you press "enter" in the address bar of Firefox, it's loading the swf from the cache, and the event never happens.

Firefox does however seem to fire the Event.INIT event every time, so this is how I solved the issue:

In my document class constructor:

this.loaderInfo.addEventListener (Event.INIT, onInit);
this.loaderInfo.addEventListener (Event.COMPLETE, initPlayer);

The onInit function:

private function onInit(e:Event):void {
        //if file is already loaded via cache, bytesLoaded should equal bytesTotal
    if(this.loaderInfo.bytesLoaded >= this.loaderInfo.bytesTotal){
     this.loaderInfo.removeEventListener(Event.INIT, onInit);
     this.loaderInfo.removeEventListener(Event.COMPLETE, initPlayer);
     initPlayer(e);
     }  
}
Kim L