Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 174

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

Advertisement

However, if a child component dispatches an event, and you want that opportunity to handle
the event outside of the component, you must add logic to your custom component to
propagate the event. Notice that the event listener for the
control propagates the event. This lets you handle the event in your application, as the
following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<mx:Script>
<![CDATA[
import flash.events.Event;
function handleText(eventObj:Event)
{
...
}
]]>
</mx:Script>
<MyComp:ModalText changed="handleText(event);"/>
</mx:Application>
Creating the ModalText component
The following code example implements the class definition for the ModalText component.
The ModalText component is a composite component that contains a
TextArea
control. The following image shows this control:
This control has the following attributes:
You cannot edit the TextArea control by default.
You click the Button control to toggle editing of the TextArea control.
You use the
textPlacement
right side or the left side of the control.
Editing the
textPlacement
event.
You use the
text
Editing the
text
Editing the text in the TextArea control dispatches the
174
Creating Advanced Visual Components in ActionScript
property of the control to make the TextArea appear on the
property of the control dispatches the
property to programmatically write content to the TextArea control.
property of the control dispatches the
event for the TextArea
change
Button
control and a
placementChanged
event.
textChanged
event.
change

Advertisement

Table of Contents
loading

Table of Contents