Flash CS3 Documentation |
|||
| Using ActionScript 2.0 Components > Creating Components > Creating the ActionScript class file > About core functions | |||
You must define five functions in the component class file: init(), createChildren(), the constructor function, draw(), and size(). When a component extends the UIComponent, these five functions in the class file are called in the following order:
init() Any initialization occurs during the init() function call. For example, instance member variables can be set at this time and the component bounding box can be hidden.
After init() is called, the width and height properties are automatically set. See Defining the init() method.
createChildren() Called as a frame plays in the Timeline. During this time, the component user can call methods and properties to set up the component. Any subobjects the component needs to create are created within the createChildren() function. See Defining the createChildren() method.
Called to create an instance of the component. The component constructor function is generally left empty to avoid initialization conflicts. See About the constructor function.
draw() Any visual elements of the component that are programmatically created or modified should occur within the draw function. See Defining the draw() method.
size() This function is called whenever a component is resized at runtime and is passed updated width and height properties of the component. Component subobjects can be sized or moved in relation to the component's updated width and height properties within the size() function. See Defining the size() method.
These core component functions are described in detail in the sections that follow.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002507.html