To create a component decide which class to extend, methods to implement/override and properties. Take care that you will need to declare any events that the component will dispatch. For visual components we will need to override createChildren() and updateDisplayList() methods as they are needed by flex to create children.
To embed a resource into the component use [Embed("../pathToAsset/asset.jpg")] metadata tag and follow with declaration of a property name to be used to hold reference to the same data-typed to Class.
On the backend when we create a component, the initialization sequence is as follows:
Constructor
createChildren()
commitProperties()
measure()
updateDisplayList()
In most cases we will need to override createChildren() and updateDisplayList().
commitProperties() override needed if we need to set properties dependent on other properties already set. Called after all children have been created.
measure() override needed if we want to manually calculate height and width of all the children created. Used to contain new containers with unique layout rules.
Children can be created and added to a component using addChild() and addChildAt() methods
Questions:
- How will you embed a resource into a component?
- What is the initialization sequence when a component is created (key methods)?
- In the sequence in Q2, which methods will you need to override? Explain.
- How can you create children for a component?
No comments:
Post a Comment