views:

69

answers:

1

Does flash have properties like C#? Or do I have to create getters and setters like java?

I.E. Can I do this in flash:

public int UserID {get; private set}
+3  A: 

You will have to create getters and setters. For example,

public function set myValue (value:Number):void
{ 
            _myValue = value;
}

public function get myValue ():Number
{
           return _myValue ;
}

private var _myValue : Number;

For a read-only property provide only a getter.

Rajorshi
Both setter and getter should have same access modifier (public/private/protected). You can't have a private setter and a public getter.
Amarghosh
Good catch. Corrected.
Rajorshi
removed the down vote.
Amarghosh