MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Manual
FLEX-CREATING ADVANCED COMPONENTS MACROMEDIA Other PDF Manual (24 pages)
Text of MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Manual
MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central,
ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite,
FlashPaper, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML,
RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX,
MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS About creating components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Writing the component’s ActionScript code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Simple example of a class file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Selecting a parent class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Ab
MACROMEDIA FLEX-CREATING ADVANCED COMPONENTS Creating Advanced Components
This article describes the details of creating advanced components for use in Macromedia Flex
applications. The majority of the work is in writing the ActionScript class file, which derives from
Flex existing classes, and adding your own custom functionality.
For an additional article on creating Flex components, including examples, see
www.macromedia.com/devnet/flex/articles/creating_comp.html.
About creating components . .
Creating Advanced Components e Implement the createChildren() method.
f
Implement the commitProperties() method.
g Implement the measure() method.
h Implement the layoutChildren() method.
i
Implement the draw() method.
j
Add properties, methods, styles, events, and other metadata.
3 Compile a SWC file using compc.
The ordering of methods that you implement in this process mirrors that in the component
instantiation life cycle. By understanding which meth
Writing the component’s ActionScript code
7
Note: Macromedia recommends that you base your components on the UIComponent class rather
than the UIObject class. The UIComponent class provides more built-in functionality, but maintains
the flexibility of extending the UIObject class.
UIObject and UIComponent are the base classes of the component architecture. Understanding
the principles at work in these two classes is important for building components.
The
Creating Advanced Components The UIComponent (mx.core.UIComponent) class is a subclass of the UIObject class. It defines
high-level behaviors that are specific to a graphical object. The UIComponent class handles end-
user interactions (such as clicking and focus) and component enabling and disabling. The
UIComponent class inherits all the methods, properties, and events of the UIObject class.
Note: UIComponent also handles dragging, but you should not o
Writing the component’s ActionScript code 9
Each class can contain only one constructor method; overloaded constructor methods are not
supported in ActionScript 2.0.
Implementing the init() method
Flash calls the init() method when the class is created. At a minimum, the init() method
should call the superclass’s init() method. The width and height of the component are not set
until after this method is called.
function init(Void):Void {
super.init();
Creating Advanced Components Application performance is better when you pass style properties in the initObject argument
instead of calling the setStyle() method.
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", thi
Writing the component’s ActionScript code 11
You can set the following properties in the measure() method. Flex calculates the values of these
properties, but you can override them in the measure() method:
• _measuredMinWidth
• _measuredMaxWidth
• _measuredMinHeight
• _measuredMaxHeight
• _measuredPreferredWidth
• _measuredPreferredHeight
The properties define limits for when the object is resized. These measured properties are used for
layou
MACROMEDIA Other Owners Instructions:
| Device Model | Type of Document | Pages | Size | Views | Downloads | Updated |
|---|---|---|---|---|---|---|
COLDFUSION MX 61 - CONFIGURING AND ADMINISTERING COLDFUSION MX |
70 | 525 | 95 | 30-04-2026 | ||
FLASH MX 2004-USING FLASH |
494 | 1027 | 237 | 19-04-2026 | ||
COLDFUSION MX 61-DEVELOPING COLDFUSION MX |
860 | 1265 | 291 | 03-06-2026 | ||
DREAMWEAVER MX 2004-DREAMWEAVER API |
486 | 667 | 134 | 09-09-2026 | ||
FLASH 8-USING FLASH |
678 | 972 | 205 | 15-05-2026 | ||
BREEZE 5-MANAGER |
306 | 1201 | 217 | 05-07-2026 |