Fun at work!

Posts tagged ‘Flex’

Link

Repost: Component Life Cycle in Flex

Repost: Component Life Cycle in Flex

These are the series of methods that are called by Flex Framework for all components:
  1. As the component is going to be in a container, the parent property of the component will be referred to the container.
  2. Component’s Constructor:
    • Setup initial properties and do tasks that are not related to display of UI or not.
    • Don’t create child components or position items.
    • Constructor is called when component is created but the other lifecycle methods don’t occur until a component is added to a container.
  3. Gets the Style setting of the component.
  4. preInitialize event on the component
    • UIComponent is in a very basic stage with no children added at this time.
  5. createChildren() method is called.
    • Creates visual children of the component.
    • Flex doesn’t size or position them at this point because it doesn’t know how much screen space it has.
  6. initialize event is dispatched by the component –
    • All the component’s children are initialized.
  7. commitProperties() method
    • Is responsible to coordinate property modifications.
    • This is needed when there are multiple properties that should be set before you take action.
    • This is called when selectedIndex or selectedChild is called
    • Can be called by calling invalidateProperties(). Each time this method is called commitProperties() is scheduled to be called next time there is a screen repaint or refresh.
  8. measure() method is called only if explicit height and width is not set in the code
    • Flex calls this method to determine how much screen size a component requires.
    • This is not called when the height and width are explicitly set in the code as flex knows offhand how much screen size it will take.
    • This method sets these four properties (or you can set it)
      • measuredMinWidth
      • measuredMinHeight
      • measuredWidth
      • measuredHeight
    • LayoutManager also gets started at this point as layour manager starts with the outermost component and to size the outer most component it should know the size of its children.
    • Can be called by calling invalidateSize(). Each time this method is called measure() is scheduled to called next time there is a screen refresh.
  9. updateDisplayList() method is called
    • Is responsible for positioning of children. You can specify your children here
    • It is passed two paramters
      • unscaledWidth
      • unscaledHeight
    • Flex containers choose never to size one of their children smaller than minimum size but you can choose to override it.
    • Can be called by calling invalidateDisplayList(). Each time this method is called updateDisplayList() is scheduled to be called next time there is a screen refresh.
  10. Dispatches creationComplete event.

Tag Cloud