伊莉討論區
標題:
flash新手 AS1轉AS3 程式碼 順便附上解釋 方便易懂 謝謝各位!!
[打印本頁]
作者:
ian9356337
時間:
2012-10-31 10:57 PM
標題:
flash新手 AS1轉AS3 程式碼 順便附上解釋 方便易懂 謝謝各位!!
本帖最後由 ian9356337 於 2012-10-31 11:05 PM 編輯
xpos = ball._x;
ypos = ball._y;
ball._visible = 0;
gap = 25;
extraBorder = 15;
leftBoxVel = 4;
scritta.onRelease = function() {
xspeed = Math.random()*3+3;
yspeed = Math.random()*1+3;
ball._x = xpos;
ball._y = ypos;
ball._visible = 1;
scritta._visible = 0;
right.startDrag(true, right._x, 28, right._x, 138);
};
ball.onEnterFrame = function() {
this._x += xspeed;
this._y += yspeed;
if (this._x>=right._x && this._y>=right._y-extraBorder && this._y<=right._y+extraBorder) {
this._x -= (this._x-right._x);
xspeed = -xspeed-.5;
}
if (this._x<=left._x && this._y>=left._y-extraBorder && this._y<=left._y+extraBorder) {
this._x += (left._x-this._x);
xspeed = -xspeed;
}
if (this._y<top._y || this._y>bottom._y) {
yspeed = -yspeed;
}
if (this._x>=right._x+gap || this._x<=left._x-gap) {
xspeed = 0;
yspeed = 0;
ball._x = xpos;
ball._y = ypos;
ball._visible = 0;
scritta._visible = 1;
right.stopDrag();
}
if (ball._x<=center._x) {
lefty = left._y;
bally = ball._y;
if (lefty>=bally) {
leftspeed = (bally-lefty)/leftBoxVel;
left._y = lefty+leftSpeed;
}
if (lefty<=bally) {
leftSpeed = (lefty-bally)/leftBoxVel;
left._y = lefty-leftSpeed;
}
}
};
歡迎光臨 伊莉討論區 (http://a407.file-static.com/)
Powered by Discuz!