MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual page 43

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

The following ActionScript class file creates a component that instantiates TextArea and
Button controls:
// Import all necessary classes.
import mx.core.UIComponent;
import mx.controls.Button;
import mx.controls.TextArea;
[Event("click")]
class CompoundComponent extends UIComponent {
static var symbolName:String="CompoundComponent";
static var symbolOwner:Object = CompoundComponent;
var className:String = "CompoundComponent";
function CompoundComponent() {
}
function init() {
super.init();
invalidate();
}
// Declare two children member variables.
var text_mc:TextArea;
var mode_mc:Button;
function createChildren():Void {
if (mode_mc == undefined)
createClassObject(Button, "mode_mc", 1, { });
if (text_mc == undefined)
createClassObject(TextArea, "text_mc", 0, { preferredWidth: 150,
editable: false });
mode_mc.addEventListener("click", this);
mode_mc.label = "Click Me";
}
function layoutChildren():Void {
mode_mc.move(text_mc.width/2-5, 50);
}
// Handle events that are dispatched by the children.
function handleEvent(evt:Object):Void {
if (evt.type == "click")
text_mc.text = "the button was clicked";
}
}
Creating compound components
43

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents