Widget life cycle
http://resources.arcgis.com/en/help/flex-viewer/concepts/
Flex is an event-driven programming model. All Flex components undergo the same instantiation life cycle during which Flex automatically calls component methods, dispatches events, and makes the component visible.
Knowing the details of this life cycle will help you understand the sequence of events, which allows you to listen/wait for the proper events. This is especially important in modular applications like the Flex Viewer.
The two main parts for Flex Viewer widget development are BaseWidget and WidgetTemplate. The BaseWidget have the normal "preinitialize", "initialize", "creationComplete" events just like any other Flex component. In addition, the BaseWidget have a widgetConfigLoaded event that is dispatched when the widget has loaded its configuration file.
Basic life cycle for BaseWidget:
- preinitialize (mx.events.FlexEvent)
- initialize (mx.events.FlexEvent)
- creationComplete (mx.events.FlexEvent)
- widgetConfigLoaded (flash.events.Event)
Basic life cycle for WidgetTemplate:
- preinitialize (mx.events.FlexEvent)
- initialize (mx.events.FlexEvent)
- creationComplete (mx.events.FlexEvent)
- open or minimized (flash.events.Event)
- closed (flash.events.Event)
When using BaseWidget and WidgetTemplate together, the typical order of events is in table below:
Step | BaseWidget | WidgetTemplate |
---|---|---|
#1 |
preinitialize |
|
#2 |
preinitialize |
|
#3 |
initialize |
|
#4 |
initialize |
|
#5 |
creationComplete |
|
#6 |
open1 |
|
#7 |
creationComplete | |
#8 |
widgetConfigLoaded |
More information
- Component life cycle in our Flex API documentation.
- Adobe TV: video on components and life cycle