Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 48

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

Advertisement

In this example, you add the
the class dispatches an event named
metadata tag to indicate that the
In an MXML file, you insert the metadata tags either in an
your ActionScript code, or in an
<?xml version="1.0"?>
<!-- TextAreaEnabled.mxml -->
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Metadata>
[Event(name="enableChange", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
// Import Event class.
import flash.events.Event;
// Define class properties and methods.
private var _enableTA:Boolean;
// Add the [Inspectable] metadata tag before the individual property.
[Inspectable(defaultValue="false")]
public function set enableTA(val:Boolean):void {
_enableTA = val;
this.enabled = val;
// Define event object, initialize it, then dispatch it.
var eventObj:Event = new Event("enableChange");
dispatchEvent(eventObj);
}
]]>
</mx:Script>
</mx:TextArea>
A key difference between the
tag is inserted before the generated class declaration, but text within
<mx:Metadata>
tag is inserted in the body of the generated class declaration. Therefore,
<mx:Script>
metadata tags like
[Event]
and
[Bindable]
[Embed]
48
Using Metadata Tags in Custom Components
metadata tag before the class definition to indicate that
[Event]
enableChanged
property is accessible in Flex Builder.
enableTA
<mx:Metadata>
and
<mx:Metadata>
and
must go in an
[Effect]
metadata tags must go in an
. You also include the
<mx:Script>
block, as the following example shows:
tags is that text within the
<mx:Script>
<mx:Metadata>
tag.
<mx:Script>
[Inspectable]
block along with
tag, but the

Advertisement

Table of Contents
loading

Table of Contents