Oct 3, 2008

Deferred Instantiation

In order to optimize startup time, certain navigation containers such as Accordian, ViewStack and TabNavigator used what is called deferred creation. For Navigator containers, this means that only the container and its children, visible to the user are instantiated. The hidden containers are instantiated when focused upon.
To alter the order of instantiation Flex provides the creationPolicy property. This property is inherited by all subclasses of Container. The creationPolicy property can be altered in the following ways.

1. creationPolicy=”auto”
Flex does not create the children immediately, but instantiated them only when the user focuses on them. This deferred instantion raises the performance in that the navigatore container loads quickly. However, the user may experience a brief pause for the first time they navigate among containers.
If this attribute is set for a non-navigator component, then we must specify additional code to specify the order of creating the children.

2. creationPolicy=”all”
Flex instantiates all components. However, this may reduce the initial load time.

3. creationPolicy=”none”
Flex does not instantiate any of the components unless the programmer explicitly calls the instantiation methods (done through createComponents() method).

4. creationPolicy=”queued”
Flex instantiates the components one after the other. The order can be altered using the creationIndex property. If creationIndex is not assigned, the children are instantiated in the order they appear in the MXML.

However, deferred instantiation has its own set of disadvantages. Deferred instantiation is not usually preferred when using effects and transitions. It usually gets in the way of smooth transition performance because instantiation may occur in mid transaction. Of course, this may be only for the first time the transition is played.

Thanks,
Shaleen Jain

1 comment:

  1. Excellent explaination...gr8 work Shaleen

    ReplyDelete