Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 124

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Your class must be specified as
tag.
In this example, you first define the
component. You then reference the component as an MXML tag by using the namespace
prefix.
You can specify any inherited properties of the superclass in MXML, as the following example
shows:
<?xml version="1.0"?>
<!-- as/MainDeleteTextAreaProps.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:DeleteTextArea wordWrap="true" text="My Message"/>
</mx:Application>
You do not have to change the name of your custom component when you create a subclass of
a Flex class. In the previous example, you could have named your custom component
TextArea, and written it to the TextArea.as file in the myComponents directory, as the
following example shows:
package myComponents
{
import mx.controls.TextArea;
import flash.events.KeyboardEvent;
public class TextArea extends mx.controls.TextArea {
...
}
}
You can now use your custom TextArea control, and the standard TextArea control, in an
application. To differentiate between the two controls, you use the namespace prefix, as the
following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*" >
<MyComp:TextArea/>
<mx:TextArea/>
</mx:Application>
124
Creating Simple Visual Components in ActionScript
for you to be able to access it by using an MXML
public
namespace to specify the location of your custom
MyComp

Advertisement

Table of Contents
loading

Table of Contents