有人能帮我把这个代码从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 –