User Guide

Creating the ActionScript class file 945
If your component extends UIComponent or UIObject, Flash automatically calls init(),
createChildren(), and size() methods and you can leave your constructor function empty, as
shown here:
class MyComponent extends UIComponent{
...
// this is the constructor function
function MyComponent(){
}
}
All version 2 components should define an init() function that is called after the constructor
has been called. You should place the initialization code in the components
init() function. For
more information, see the next section.
If your component extends MovieClip, you may want to call an
init() method, a
createChildren() method, and a method that lays out your component from the constructor
function, as shown here:
class MyComponent extends MovieClip{
...
function MyComponent(){
init()
}
function init():Void{
init();
createChildren();
layout();
}
...
}
For more information about constructors, see “Constructor functions” in Using ActionScript in
Flash.
Defining the init() method
Flash calls the
init() method when the class is created. This method is called once when a
component is instantiated and never again.
You should use the
init() method to do the following:
Call super.init().
This is required.
Make the boundingBox_mc invisible.
boundingBox_mc.width = 0;
boundingBox_mc.height = 0;
boundingBox_mc.visible = false;
Create instance member variables.
The
width, height, and clip parameters are properly set only after this method is called.