In my ActionScript3 class, can I have a property with a getter and setter?
views:
3947answers:
2
+11
A:
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;
}
}
}
Max Stewart
2008-09-29 22:59:53
+2
A:
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
JustFoo
2008-09-29 23:02:04