This example contains a minimal set of imports, methods, and declarations for a component,
MyComponent, that inherits from the UIComponent class. The MyComponents.as file is saved
in the myPackage folder.
[Event("eventName")]
// Import packages.
import mx.core.UIObject;
// Declare the class and extend from the parent class.
class mypackage.MyComponent extends UIObject {
// Identify the symbol name that this class is bound to.
static var symbolName:String = "mypackage.MyComponent";
// Identify the fully qualified package name of the symbol owner.
static var symbolOwner:Object = Object(mypackage.MyComponent);
// Provide the className variable.
var className:String = "MyComponent";
// Define an empty constructor.
function MyComponent() {
}
// Call the parent's init method.
// Hide the bounding box--it's used
// only during authoring.
function init():Void {
super.init();
boundingBox_mc.width = 0;
boundingBox_mc.height = 0;
boundingBox_mc.visible = false;
}
function createChildren():Void{
// Call createClassObject to create subobjects.
size();
invalidate();
}
function size(){
// Write code to handle sizing.
super.size();
invalidate();
}
function draw(){
// Write code to handle visual representation.
super.draw();
}
}
Creating the ActionScript class file
931
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?
Questions and answers