Macromedia flex 2 Manuale

Pagina di 254
126
Creating Simple Visual Components in ActionScript
return _prop1;
}
public function set prop1(value:Number):void {
// Typically sets the private variable to the argument. 
_prop1=value;
// Define any other logic, such as dispatching an event.
}
}
You can define and initialize a private variable, as the following example shows:
private var _prop2:Number=5;
When you specify a value to the property in MXML, Flex automatically calls the setter 
method. If you do not set the property in MXML, Flex sets it to its initial value, if you 
specified one, or to the type’s default value, which is 
NaN
 for a variable of type Number.