User Guide
Table Of Contents
- Contents
- Working with Flash MX 2004
- Creating Basic Components in Flash MX 2004
- Creating Advanced Components in Flash MX 2004
- Contents
- About Creating components
- Writing the component’s ActionScript code
- Simple example of a class file
- General process for writing a class file
- Selecting a parent class
- Identifying the class, symbol, and owner names
- About the component instantiation life cycle
- Writing the constructor
- Specifying clip parameters
- Implementing the constructObject2() method
- Implementing the init() method
- Implementing the createChildren() method
- Implementing the commitProperties() method
- Implementing the measure() method
- Implementing the layoutChildren() method
- Implementing the draw() method
- Defining getters and setters
- Component metadata
- Defining component parameters
- Handling events
- Using the Event metadata
- About invalidation
- Skinning custom controls
- Adding styles
- Making components accessible
- Improving component usability
- Best practices when designing a component
- Using the ModalText example
- Troubleshooting
- Index

Using the ModalText example 75
text_mc.move(0, 0);
}
else
{
mode_mc.move(0, 0);
text_mc.move(mode_mc.width, 0);
}
}
/*** i) implement draw ***/
// Set flags when things change so we only do what we have to.
private var bTextChanged:Boolean = true;
// Set text if it changed, and draw a border.
function draw():Void
{
clear();
if (bTextChanged)
{
bTextChanged = false;
text_mc.text = text;
}
// Draw a simple border around everything.
drawRect(0, 0, width, height);
}
/*** j) add methods, properties, metadata ***/
// The general pattern for properties is to specify a private
// holder variable.
private var __labelPlacement:String = "left";
// Create a getter/setter pair so you know when it changes.
[Inspectable(defaultValue="left", enumeration="left, right")]
function set labelPlacement(p:String)
{
// Store the new value.
__labelPlacement = p;
// Add invalidateSize(), invalidateLayout(), or invalidate(), depending on
// what changed. You may call more than one if you need to.
invalidateLayout();
}
function get labelPlacement():String
{
return __labelPlacement;
}
var __text:String = "ModalText";
[Inspectable(defaultValue="ModalText")]
function set text(t:String)
{
__text = t;