有人能幫我把這個代碼從as2轉換成as3嗎?actionscript 2到actionscript 3我的代碼
對於一個簡單的圓形,我希望當我與鼠標光標移動到右邊去,圓旋轉(不需要移動我的鼠標光標但仍一圈旋轉)
我知道_root._xmouse
去ŧ mouseX和this._rotation
去this.DisplayObject.rotation
onClipEvent(enterFrame)
{
this.xmouse = Math.min(908, Math.max(0, _root._xmouse));
if (_root._xmouse > 0)
{
var offset = Stage.width/2 - this.xmouse;
this._rotation = this._rotation + offset/2000;
} else {
this._rotation = this._rotation - 0.02;
}
this._rotation = this._rotation % 180;
}
AS3版本:
stage.addEventListener(Event.ENTER_FRAME, mouseOver);
function mouseOver(e: Event) : void
{
rota.mouseX == Math.min(908, Math.max(0, stage.mouseX));
if (stage.mouseX > 0)
{
var offset = stage.stage.width/2 - rota.mouseX;
rota.rotation = rota.rotation + offset/2000;
}else{
rota.rotation = rota.rotation - 0.02;
}
rota.rotation = rota.rotation % 180;
}
_「不需要移動我的鼠標光標,但圓形仍在旋轉」_...這就是'EnterFrame'所做的。它以您的SWF的FPS速率重複代碼。也許你想要一個'Mouse_Move'偵聽器中的代碼邏輯?顯示您嘗試製作的AS3版本代碼,更容易幫助您解決問題。 –
是的,也許是一個mouse_move監聽器,這個as2代碼如何工作(as3代碼)...? – romania
我們需要查看迄今爲止您所擁有的AS3代碼,以顯示如何應用as2邏輯。例如:沒有人知道你的圈子變量名等等。你可以用你的Circle變量名稱替換this,並將其用作'circleName.rotation = circleName.rotation%180;'etc etc –