为什么不能扩展 DisplayObject 然后实例化
Why can't extend DisplayObject then instantiate
可以扩展 DisplayObject class,但无法实例化扩展的 class。
Class:
package{
import flash.display.DisplayObject;
class Extended extends DisplayObject{
public function Extended(){
super()
}
}
}
主要时间线:
var e:Extended=new Extended();
addChild(e);
错误:
ArgumentError: Error #2012: Extended$ class cannot be instantiated.
请阅读 DisplayObject
class 的文档:
The DisplayObject class itself does not include any APIs for rendering content onscreen. For that reason, if you want create a custom subclass of the DisplayObject class, you will want to extend one of its subclasses that do have APIs for rendering content onscreen, such as the Shape, Sprite, Bitmap, SimpleButton, TextField, or MovieClip class.
可以扩展 DisplayObject class,但无法实例化扩展的 class。
Class:
package{
import flash.display.DisplayObject;
class Extended extends DisplayObject{
public function Extended(){
super()
}
}
}
主要时间线:
var e:Extended=new Extended();
addChild(e);
错误:
ArgumentError: Error #2012: Extended$ class cannot be instantiated.
请阅读 DisplayObject
class 的文档:
The DisplayObject class itself does not include any APIs for rendering content onscreen. For that reason, if you want create a custom subclass of the DisplayObject class, you will want to extend one of its subclasses that do have APIs for rendering content onscreen, such as the Shape, Sprite, Bitmap, SimpleButton, TextField, or MovieClip class.