Professional Documents
Culture Documents
and Spark
Deepa Subramaniam
Flex SDK
http://www.iamdeepa.com
Parts: Internal parts of a component that are composited together to create a whole
component.
Composition is the name of the game.
3 Phase Lifecycle
1. Initialization
Construction
Configuration
Attachment
Initialization
2. Updating
Component responds to changes by using the Invalidation/Validation Model
3. Destruction
Out of sight, out of mind
Detachment
Garbage collection
Construction
Construction: Component begins its lifecycle
Configuration
Attachment
Decide on the right base-class
Initialization
Invalidation Component is instantiated, through the new operator in ActionScript
Validation or in markup
Detachment Constructor must have zero required arguments
Garbage Collection
Constructor can add event listeners, hard code initialization
properties of super classes
Minimal work should occur here.
Construction
Configuration
Attachment: Addition to the display list
Attachment What is the display list?
Initialization
Invalidation
Component is added to the display list through an
Validation addChild() call by its parent.
Detachment Without attachment, component lifecycle will stall.
Garbage Collection
Construction Initialization
Configuration
Full invalidation/validation cycle is invoked (we
Attachment
will come back to this)
Initialization
5 main lifecycle actions occur at this step:
Invalidation
Validation 1. preinitialize event is dispatched
Detachment
2. createChildren() is called
Garbage Collection
3. initialize event is dispatched
4. First full invalidation/validation pass occurs
5. creationComplete event is dispatched
Halo Rules:
1. UIComponents can contain anything (Sprites, Shapes, MovieClips, Video,
etc).
2. UIComponents must go inside other UIComponents
3. Containers must contain only UIComponents
Phase 1 Done!
Waiting for
update request Validation occurs right
before Rendering
Update
Requested
Invalidation
Validation
invalidateProperties() commitProperties()
invalidateSize() measure()
invalidateDisplayList() updateDisplayList()
Construction
Destroying the component
Configuration Detachment: Remove the component from the display list
Attachment Components do not get validated or drawn when off the display list
Initialization
Invalidation
Once off the display list:
Validation You can re-parent the component, and it will be brought back to
Detachment life.
Garbage Collection Re-parenting is cheaper then re-instantiating a component
Garbage Collection
No active references can be tough
Common culprits include event listeners, dictionaries and timers.
Component Skin
Default layout
Data model
Default size
Event Handling
Definition View States
Skin Parts Contract
Definition of Skin Parts
View States Contract
Graphics for data representation
2.
We continue to optimize!
Spark skinning comes with a cost, but its deemed “in the noise”
Flash Player Elastic Racetrack: Learn it, love it, live it.
Invalidation: All the cool kids are doing it.
The best component lifecycle reference is right in front of you: Read Framework Code.
http://www.iamdeepa.com/
http://opensource.adobe.com/wiki/display/flexsdk/Gumbo
http://opensource.adobe.com/wiki/display/flexsdk/Gumbo+Component+Architecture
Thank You.