Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 128

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

Advertisement

}
}
}
}
}
Notice that the call to the
event. You must wait until component creation is complete before calling
creationComplete
to ensure that Flex has set all inherited styles. However, you can call
getStyle()
in the component constructor to set styles.
This example uses variables to define public properties to control the maximum font size,
, and minimum font size,
maxFontSize
properties in MXML, as the following example shows:
<?xml version="1.0"?>
<!-- as/MainTextAreaFontControl.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:TextAreaFontControl id="myTAFS"
minFontSize="8"
maxFontSize="50"/>
<mx:Button
label="Get Font Size"
click="myTA.text=String(myTAFS.getStyle('fontSize'));"/>
<mx:TextArea id="myTA"/>
</mx:Application>
Defining public properties by using getter and setter methods
There are no restrictions on using public variables to define public properties, However,
Adobe recommends that you use getter and setter methods so that you can control user
interaction with your component, as described in
on page
30.
128
Creating Simple Visual Components in ActionScript
}
break;
// Was Ctrl-M pressed?
case 77 :
if (currentFontSize > minFontSize) {
currentFontSize = currentFontSize - 1;
setStyle('fontSize', currentFontSize);
}
break;
default :
break;
method is in the event listener for the
getStyle()
minFontSize
, of the control. Users can set these
"Defining properties as getters and setters"
setStyle()

Advertisement

Table of Contents
loading

Table of Contents