Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 104

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

Advertisement

You could make the custom component slightly more reusable by using the
property to reference the TextArea control, rather than the
mx.core.Application.application
property, you can call the custom component from any other MXML component that
contains a TextArea control named myTAMain, as the following example shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/myComponents/StateComboBoxDirectRefParentObj.mxml -->
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
close="handleCloseEvent(event);">
<mx:Script>
<![CDATA[
import flash.events.Event;
public function handleCloseEvent(eventObj:Event):void {
parentDocument.myTAMain.text=String(selectedIndex);
}
]]>
</mx:Script>
<mx:dataProvider>
<mx:Array>
<mx:String>AK</mx:String>
<mx:String>AL</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
Although these examples work, they require that the
property, and that MXML component knows that
example of a tightly coupled component. That is, the component is written for a specific
application and application structure, and it not easily reused in another application.
104
Creating Advanced MXML Components
static property. By using the
TextArea
. In this case, custom component is an
id
parentDocument
parentDocument
control has a predefined
id

Advertisement

Table of Contents
loading

Table of Contents