ActionScript Getters and Setters

http://fupeg.blogspot.com/2007/11/actionscript-getters-and-setters.html

It’s always nice when a programming language surprises you in a pleasant way. ActionScript 3 has get/set property syntax, very similar to C#:

public class Person implements IPerson
{
private var m_name:String;

public function get name():String
{
return m_name;
}

public function set name(value:String):void
{
m_name = value;
}
}

What was an even nicer surprise is that you can define properties in an ActionScript interface:

public interface IPerson
{
function get name():String;
function set name(value:String):void;
}

And then write code that makes it look like you’re accessing the field of an inteface:

var person:IPerson = new Person();
person.name = “Michael”;

Now if only we had this syntactic sugar in Java…