flash代码解释

来源:百度知道 编辑:UC知道 时间:2024/06/18 17:31:44
onClipEvent (load) {
xStep = 10;
yStep = 10;
}
onClipEvent (enterFrame) {
if ((getBounds(_root).xMax>800) || (getBounds(_root).xMin<0)) {
xStep *= -1;
}
if ((getBounds(_root).yMax>400) || (getBounds(_root).yMin<0)) {
yStep *= -1;
}
this._x += xStep;
this._y += yStep;
if (xStep<0) {
_root.mm._x = this._x+10;
_root.mm1._x = this._x+20;
_root.mm2._x = this._x+30;
}
if (xStep>0) {
_root.mm._x = this._x-10;
_root.mm1._x = this._x-20;
_root.mm2._x = this._x-30;
}
if (yStep>0) {
_root.mm._y = this._y-10;
_root.mm1._y = this._y-20;
_root.mm2._y = this._y-30;
}
if (yStep<0) {
_root.mm._y = this._y+10;
_root.mm1._y = this._y+20;
_root.mm2._y = this._y+30;
}
}
各位大侠,本人为新手,最好是一行一解释,送高分!

onClipEvent (load) {//影片剪辑装载事件
xStep = 10;//水平方向步长
yStep = 10;//垂直方向步长
}
onClipEvent (enterFrame) {//影片剪辑输入帧事件(实现循环)
if ((getBounds(_root).xMax>800) || (getBounds(_root).xMin<0)) {
xStep *= -1;
}//判断,如果最大横坐标大于800或者最小横坐标小于0,那么x步长变为负值
if ((getBounds(_root).yMax>400) || (getBounds(_root).yMin<0)) {
yStep *= -1;
}//类似于上面,不过是纵坐标
this._x += xStep;//当前剪辑按帧速率向右运动
this._y += yStep;//当前剪辑近帧速率向下运动
if (xStep<0) {
_root.mm._x = this._x+10;
_root.mm1._x = this._x+20;
_root.mm2._x = this._x+30;
}//如果x步长小于0,那么主场景中三个剪辑mm,mm1,mm2的横坐标位于当前剪辑右边分别10,20,30
if (xStep>0) {
_root.mm._x = this._x-10;
_root.mm1._x = this._x-20;
_root.mm2._x = this._x-30;
}//如果x步长大于0,那么主场景中三个剪辑mm,mm1,mm2的横坐标位于当前剪辑左边分别10,20,30
if (yStep>0) {
_root.mm._y = this._y-10;
_root.mm1._y = this._y-20;
_root.mm2._y = this._y-30;
}//原理同上,不过是纵坐标