You can use the
[DefaultProperty]
a single default property, as the following example shows:
package myComponents
{
// as/myComponents/TextAreaDefaultProp.as
import mx.controls.TextArea;
// Define the default property.
[DefaultProperty("defaultText")]
public class TextAreaDefaultProp extends TextArea {
public function TextAreaDefaultProp()
{
super();
}
// Define a setter method to set the text property
// to the value of the default property.
public function set defaultText(value:String):void {
if (value!=null)
text=value;
}
public function get defaultText():String {
return text;
}
}
}
In this example, you add a new property to the TextArea control, called
and specify it as the default property of the control. The setter method for
just sets the value of the
MXML, as the following example shows:
<?xml version="1.0"?>
<!-- as/MainTextAreaDefaultProp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:TextAreaDefaultProp>Hello</MyComp:TextAreaDefaultProp>
</mx:Application>
metadata tag in your ActionScript component to define
property of the control. You can then use the default property in
text
Adding properties and methods to a component
,
defaultProperty
defaultProperty
131