1,ActionScript 3.0已经完全OO,所有AS代码都必须写在类里
2,AS的package和Java一样是与物理目录对应的,com.hideto.MessageManager类必须保存在com/hideto/MessageManager.as
3,属性声明
private var count:uint;
4,implicit getters and setters
package {
public class Counter {
private var _count:uint;
public function Counter() {
_count = 0;
}
public function get count():uint {
return _count;
}
public function set count(value:uint):void {
if(value < 100) {
_count = value;
} else {
throw Error();
}
}
}
}
这样可以直接使用counter.count,get和set让count方法变成一个public属性
5,静态方法与静态属性
public static test():void {}
private static var _example:String;
6,继承
public class Subclass extends Superclass
7,常量
public static const EXAMPLE:String = "example";
8,事件分发
要想使用addEventListener()和removeEventListener(),类必须继承EventDispatcher(Sprite就继承自EventDispatcher)