PDA

View Full Version : Running functions when page is loaded


angerbee
03-15-2009, 02:45 AM
I am looking for the Flex equivalent of onLoad() in ASP.Net. I need to run some initialization code before the user can use the page, but I cannot find a way. I tried just typing the code, but most of the object library code will not work outside of a function. Then when I encapsulate it in a function, I cannot call it by

function();

or

this.function();

Sly_cardinal
03-15-2009, 06:37 AM
Have a look at the creationComplete (http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#event:creationComplete) event of the UIComponent class.

This is an event that is dispatched when a component (and its children) has been fully initialised.

There is also the ApplicationComplete (http://livedocs.adobe.com/flex/3/langref/mx/core/Application.html#event:applicationComplete) event which is pretty much the same, just more specific for the Application class. That link includes an example of using the ApplicationComplete event.