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 object’s 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.
Содержание FLEX 2 - CREATING AND EXTENDING COMPONENTS
Страница 1: ...Creating and Extending Flex 2 Components Adobe Flex 2...
Страница 6: ...6 Contents...
Страница 10: ...10 About Flex Documentation...
Страница 12: ......
Страница 24: ...24 Creating Flex Components...
Страница 74: ...74 Compiling Components...
Страница 76: ......
Страница 118: ...118 Creating Advanced MXML Components...
Страница 120: ......
Страница 182: ...182 Creating Advanced Visual Components in ActionScript...
Страница 194: ...194 Creating Custom Style Properties...
Страница 204: ...204 Creating Template Components...
Страница 206: ......
Страница 216: ...216 Creating Custom Formatters...
Страница 254: ...254 Index...