Chapter 5: Using Metadata Tags In Custom Components; About Metadata Tags - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

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

Advertisement

About metadata tags

Metadata tags provide information to the Flex compiler that describe how your components
are used in a Flex application. For example, you might create a component that defines a new
event. To make that event known to the Flex compiler so that you can reference it in MXML,
you insert the
[Event]
definition shows:
[Event(name="enableChanged", type=flash.events.Event)]
class ModalText extends TextArea {
...
}
In this example, the
[Event]
the type of the event object dispatched by the event. After you identify the event to the Flex
compiler, you can reference it in MXML, as the following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:MyComp="*">
<mx:Script>
<![CDATA[
function handleEnableChangeEvent(eventObj:Event):void {
...
}
]]>
</mx:Script>
<MyComp:ModalText enableChanged="handleEnableChangeEvent(event);"/>
</mx:Application>
If you omit the
[Event]
when it compiles your MXML file. The error message indicates that Flex does not recognize
the
property.
enableChanged
46
Using Metadata Tags in Custom Components
metadata tag into your component, as the following ActionScript class
metadata tag specifies the event name, and the class that defines
metadata tag from your class definition, Flex issues a syntax error

Advertisement

Table of Contents
loading

Table of Contents