User Guide
Creating the ActionScript class file 161
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” on page 162.
■ 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” on page 162.
■ Constructor function
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”
on page 164.
■ draw()
Any visual elements of the component that are programmatically created or modified
should occur within the draw function. See “Defining the draw() method” on page 165.
■ 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” on page 165.
These core component functions are described in detail in the sections that follow.