Flex 3: mx:Application.applicationComplete vs creationComplete
I'm working on a media player in Flex and I ran into an issue.
Background
When you click the "Fullscreen" button I change the label to "Exit Fullscreen" and vice versa when you click it again. If you use ESC key to return from fullscreen the label stays the same.
No problem right? I'll add
stage.addEventListener(FullScreenEvent.FULL_SCREEN, handleFullScreen);
to my init() function which is called from the creationComplete and I'm done, right?
Problem
"creationComplete":http://livedocs.adobe.com/labs/flex3/langref/mx/core/UIComponent.html#event:creationComplete - "Dispatched when the component has finished its construction, property processing, measuring, layout, and drawing."
Basically, when creationComplete is called the stage object is null. Huh? Yep, that's right...it is null.
Solution
I found a blog post by Raghu where he talked about using the SystemManager. That seems really hack'sh (which he felt the same as well). He then pointed out a blog post by Wietse Veenstra which shows the start-up order.
Bottom line, applicationComplete is the event we should use for init'ing our application. creationComplete should be used for init'ing children of the application, if needed.
Hopefully this will help someone as it has helped me. God bless the blogosphere! ;-)
Categories
Flash Platform0 TrackBacks
Listed below are links to blogs that reference this entry: Flex 3: mx:Application.applicationComplete vs creationComplete.
TrackBack URL for this entry: http://mt.johncblandii.com/mt-tb.cgi/78


Yo man! thanks for the tip! you've been a great help posting this info!
No sweat man.
Use "callLater":
creationComplete="callLater(init)"
;)
Yeah, but why? applicationComplete is what I use and suggest you use.