![MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Скачать руководство пользователя страница 47](http://html1.mh-extra.com/html/macromedia/flex-developing-components-and-themes/flex-developing-components-and-themes_manual_3388115047.webp)
Writing the component’s ActionScript code
47
Simple example of a class file
The following is a simple example of a class file called MyComponent.as. If you were creating this
component, you would link this file to the component in the Flash IDE.
This example contains a minimal set of imports, methods, and declarations for a component that
inherits from the UIObject class.
//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() {
}
// Override the init method, and call the parent’s init method.
function init(Void):Void {
super.init();
// Call invalidate() to display graphics.
invalidate();
}
}
General process for writing a class file
Use the following general process when you write a component’s ActionScript class file.
Depending on the type of component that you create, whether you override any of the superclass’s
methods is optional. For the simplest form of component, you are not required to implement any
of these methods.
To write the ActionScript file for a component:
1.
Select and extend a parent class.
2.
Define the
symbolName
,
symbolOwner
, and
className
properties.
3.
Write an empty class constructor.
4.
Specify properties that can be set using an MXML tag property (clip parameters).
5.
Implement the
constructObject2()
method.
6.
Implement the
init()
method.
Содержание FLEX - DEVELOPING COMPONENTS AND THEMES
Страница 1: ...Developing Flex Components and Themes in Flash Authoring ...
Страница 4: ...4 Contents ...
Страница 44: ...44 Chapter 2 Creating Basic Components in Flash MX 2004 ...
Страница 82: ...82 Index ...