Widget life cycle

This page describes an older version, please read about the latest version at:
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:

  1. preinitialize (mx.events.FlexEvent)
  2. initialize (mx.events.FlexEvent)
  3. creationComplete (mx.events.FlexEvent)
  4. widgetConfigLoaded (flash.events.Event)

Basic life cycle for WidgetTemplate:

  1. preinitialize (mx.events.FlexEvent)
  2. initialize (mx.events.FlexEvent)
  3. creationComplete (mx.events.FlexEvent)
  4. open or minimized (flash.events.Event)
  5. 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

1: Open or minimized. The latter if widget is preloaded as minimized and open for all other cases.

More information

2/15/2012