Applying Styles To Custom Components - 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

If you do not identify an event in the class file with the
generates an error when an MXML component attempts to register a listener for that event.
Any component can register an event listener for the event in ActionScript using the
addEventListener()
You can then handle the event in MXML, as the following example shows:
<?xml version="1.0"?>
<!-- as/MainModalTextEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComps="myComponents.*">
<mx:Script>
<![CDATA[
import flash.events.Event;
private function handleEnableChanged(event:Event):void {
myTA.text="Got Event";
}
]]>
</mx:Script>
<MyComps:ModalTextEvent id="myMT"
enableChanged="handleEnableChanged(event);"/>
<mx:Button click="myMT.enableInput(true);"/>
<mx:TextArea id="myTA"/>
</mx:Application>

Applying styles to custom components

Style properties define the look of a component, from the size of the fonts used to the color of
the background. Your custom ActionScript components inherit all of the styles of the base
class, so you can set them in the same way as for that base class.
To change style properties in custom components, use the
component's constructor. This applies the same style to all instances of the component, but
users of the component can override the settings of the
Any style properties that are not set in the component's class file are inherited from the
component's superclass.
144
Creating Simple Visual Components in ActionScript
method, even if you omit the
metadata tag, the compiler
[Event]
metadata tag.
[Event]
method in the
setStyle()
method in MXML tags.
setStyle()

Advertisement

Table of Contents
loading

Table of Contents