User Guide

Creating the ActionScript class file 163
The following table describes the parameters:
To call
createClassObject(), you must know what the children are, because you must
specify the name and type of the object, plus any initialization parameters in the call to
createClassObject().
The following example calls
createClassObject() to create a new Button object for use
inside a component:
up_mc.createClassObject(mx.controls.Button, "submit_btn", 1);
You set properties in the call to createClassObject() by adding them as part of the
initObject parameter. The following example sets the value of the label property:
form.createClassObject(mx.controls.CheckBox, "cb", 0, {label:"Check
this"});
The following example creates TextInput and SimpleButton components:
function createChildren():Void {
if (text_mc == undefined)
createClassObject(TextInput, "text_mc", 0, { preferredWidth: 80,
editable:false });
text_mc.addEventListener("change", this);
text_mc.addEventListener("focusOut", this);
if (mode_mc == undefined)
createClassObject(SimpleButton, "mode_mc", 1, { falseUpSkin:
modeUpSkinName, falseOverSkin: modeOverSkinName, falseDownSkin:
modeDownSkinName });
mode_mc.addEventListener("click", this);
size()
invalidate()
}
Parameter Type Description
className
Object The name of the class.
instanceName
String The name of the instance.
depth
Number The depth for the instance.
initObject
Object An object that contains initialization properties.