我在flashcs6里先建立了新文件,ActionScript 3.0,然后在舞台上导入一张图片并转化为元件,然后设置元件属性,勾选了为AcitonScript 导出,类的名称写为:helfMC,然后点击后面的铅笔在文档里输入了如下代码:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public function helfMC( ) {
trace("helf created: " + this.name);
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, clickHandler);
this.addEventListener(MouseEvent.MOUSE_DOWN,
mouseDownListener);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
}
private function clickHandler(event:MouseEvent):void {
trace("You clicked the picture");
}
function mouseDownListener(event:MouseEvent):void {
this.startDrag( );
}
function mouseUpListener(event:MouseEvent):void {
this.stopDrag( ); }
}
fla和as都存在同一个目录下,但是测试影片的时候报错: private 属性只能用于类属性定义。可是教程里的函数也是这么写的呀,这怎么改?