FLASH AS3.0 求每句代码注释。。。(空战游戏)。。。

package classes

{

import flash.display.Sprite

import flash.utils.Timer

import flash.events.*

public class Boss extends Sprite

{

//速度变量

private var speed:int;

//这个变量很有问题,在类内是严禁这样声明变量的。这有违类的封装。

//计数器

public var blood:int=100;

public function Boss()

{//在构造函数内初始化变量,并创建帧频事件

speed=3;

//将本身的坐标设置为0,其实应该在前面加上this

y=0;

this.addEventListener(Event.ENTER_FRAME,moveBoss);

}

private function moveBoss(e:Event):void

{//事件函数,其实就是帧频函数

//让对象以speed的速度运动

x+=speed;

//判断坐标,当对象移出舞台右边时,要执行的命令,这里是一个折反运动

if(x>550-this.width||x<0)

speed=-speed;

//如果blood为0,删除帧频事件,结果就是让对象停止移动

if(blood==0)

this.removeEventListener(Event.ENTER_FRAME,moveBoss)

}

}

}