Initialization phase of flash player in browser

Just thought I should share a little experience I had with embedding flash content on webpages.  If you’re application has a dynamic width and height (IE. You are sizing your content based on the size of the embed), you need to listen for Event.RESIZE to initialize your application properly. Here are a couple of implementation issues I’ve had with dynamically resized apps:

  • When you embed with Javascript, the stage size directly after load is 0×0.  IE… stage.stageWidth = 0 until the javascript kicks in and stretches the layout properly.
  • When you are not using javascript to embed flash content, the stage size is implemented properly if the .swf hasn’t been cached by the browser.  I ran into this issue where the flash file would implement the stage properly the first time.  However, when visiting the same flash page again, the stageWidth and stageHeight would start out as 0.

By adding a stage listener to detect resizes, issues of rendering the interface based on stage properties can be avoided.  I should mention that both cases of rendering the page on load and on resize must be implemented to avoid edge cases.