User Guide

140 Creating Simple Visual Components in ActionScript
You can use your custom component in the following Flex application:
<?xml version="1.0"?>
<!-- as/MainCodeBehindExample.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComps="myComponents.*">
<MyComps:MyPanelComponent id="myP"/>
<mx:Button label="Copy" click="myP.xfer();"/>
</mx:Application>
If the value of the id property of a TextInput control does not match an inherited property
name, Flex creates a property of the component, where the
id property defines the name of
the new property.
To support initialization from MXML, an inherited property must have the following
characteristics:
The inherited property must be public.
If you try to initialize a non-public inherited property, the Flex compiler issues an error.
The inherited property must be writable.
If you try to initialize a constant, or a property defined by a getter method without a
corresponding setter method, the Flex compiler issues an error.
The data type of the value that you specify to the inherited property must by compatible
with the data type of the property.
If you try to initialize a property with a value of an incompatible data type, the Flex
compiler issues an error.
Defining events in ActionScript
components
Flex components dispatch their own events and listen to other events. An object that wants to
know about another objects events registers as a listener with that object. When an event
occurs, the object dispatches the event to all registered listeners.
The core class of the Flex architecture, mx.core.UIComponent, defines core events, such as
updateComplete, resize, move, creationComplete, and others that are fundamental to all
components. Subclasses of these classes inherit and dispatch these events.