Example of get | Read only accessor | ActionScript 3 AS3

##"get" example in AS3##
Please post any other examples you may have in the comments.
public function get toolTip():String{
return _toolTip;
}
Get is used to create read only properties on a class. It is used in combination with a function declaration in a class to create properties that are actually functions.
It is not advised that you use them unless read only access is necessary, the danger of using these is that they can often look like real properties rather than functions which can sometimes be confusing while debugging.
It is also advised not to put any code other than return property in a get function because again it can look like a property is simply being accessed and it can easily be missed that a whole lot more went on while that property was being accessed. However if you are trying to create a black box class for distribution and you want to obfuscate your code by all means put as much code in the get accessor as you want.


comments powered by Disqus