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…

AS3 TextField buttonMode or useHandCursor?

I was trying to find the answer of using TextField as button.

and here is the answer i found from google. :)

======== from http://www.adenforshaw.co.uk/?p=168 ========

Unfortunatly, no method exits on the TextField class in AS3 as it does not extend the Sprite class, which contains the buttonMode property.

This is most apparent with the annoying problem of having a TextField inside your Sprite/MovieClip you;re trying to use as a button, where even after setting buttonMode = true on the button, rolling over the textfield inside the button will revert the Cursor back to default.ac

To get round this simply use the mouseChildren = false property on your Sprite/Movieclip button.

i.e.

myTextFieldContainingSprite.buttonMode = true;

myTextFieldContainingSprite.mouseChildren = false;

myTextFieldContainingSprite.addEventListener(MouseEvent.MOUSE_DOWN …… etc