In my ActionScript3 class, can I have a property with a getter and setter?
Ok, well you can just use the basic getter/setter syntax for any property of your AS3 class. For example
package {
public class PropEG {
private var _prop:String;
public function get prop():String {
return _prop;
}
public function set prop(value:String):void {
_prop = value;
}
}
}
Yes you can create getter and setter functions inside an AS3 class.
Example:
private var _foo:String = "";
public function get foo():String{
return _foo;
}
public function set foo(value:String):void {
_foo= value;
}
more information about getters and setters can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With