The problem where the player does not initialize correctly is still present in 3.1.5 under Firefox for the Mac.
The problem is that stage.stageWidth and stage.stageHeight are zero in many cases. The timer fix that Anssi mentioned in 3.1.3 (above) still doesn't fix the issue, and when we've traced it, we discovered that the timer was simply hung in a loop waiting for the stage size to change, and it never did. This was easily reproducable at one of the sites which virally embeds our player
http://iste-eduverse.org, so it was easy for me to add special tracing to the player and debug this.
This problem is pretty well documented.
There is an Adobe JIRA bug report for it:
http://bugs.adobe.com/jira/browse/FP-434
And this is a good discussion by people experiencing the problem:
http://www.stevensacks.net/2009/01/20/firefox-3-mac-flash-bug-stagewidth-and-stageheight-are-0/
Suggested fixes have been:
- Add a timer and wait until the stage is set. (Does not appear to work reliably).
- Setting stage.scaleMode to force a resize, then waiting for the resize event. (Tried this extensively, did not work reliably).
- Using Event.ENTER_FRAME and waiting for the stage size to be set before proceeding (seemed to work best for us).
Here is what we did to the code:
- Removed the timer code completely along with Event.COMPLETE triggering of init(), plus other multiple init() references. This may not have been necessary but it eliminated many of the uncertainties about timing issues by removing multiple entry points to init() and helped us focus on one solution.
- onAddedToStage sets up an event listener for Event.ENTER_FRAME.
- When onEnterFrame has a non-zero stage size, it calls init() (this is the only place init is called in our code.)
This seems to work reliably in Firefox for the Mac, Safari for Mac, IE8 and IE7.
There are still some issues. On Firefox for the Mac, players "below the fold" do not actually initialize until you scroll down to view them. This is a bit odd and I wish I knew how to do this intentionally because I like the idea of knowing when a player has been viewed vs. simply being rendered. But, it appears that only Firefox on the Mac exhibits this behavior. Safari does not and Windows browsers do not. It does work very reliably however, despite the "late rendering".
The "preloading rotation animation" does not work well at all. This is because the stageHeight and stageWidth definitely are not available until later in the loading phase. I believe that there is no way to reliably get these numbers at the point they are needed. So, one possible option (we did not bother with) is to see if the height and width of the application container could be derived some other way, such as using loaderInfo. Fortunately, the animation does not appear at all in most cases, and when it does it appears as a white object on a white background in our case.
The whole Preloader.as file looks like it could use some real testing and scrutiny, as the entire AS3/Flex community appears a bit befuddled about the exact behavior of objects during the preload phase and there is no definitive information from Adobe.
I am not posting any source code here because of licensing issues, but I have it available in our svn.