Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In my ActionScript3 class, can I have a property with a getter and setter?

In my ActionScript3 class, can I have a property with a getter and setter?

like image 207
Pavel Chuchuva Avatar asked Nov 29 '22 21:11

Pavel Chuchuva


2 Answers

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;
        }
    }
}
like image 69
Max Stewart Avatar answered Dec 09 '22 10:12

Max Stewart


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

like image 22
JustLogic Avatar answered Dec 09 '22 11:12

JustLogic