Actionscript 如何以最大/最小角度停止旋转的电影剪辑?
我有一个按钮(减少),当按下按钮时,箭头向左旋转。我需要箭头以一定角度停止(大约在8点钟) 如何获取箭头的角度,然后阻止它旋转超过此点(即使用户一直按下按钮) 这是我的密码:Actionscript 如何以最大/最小角度停止旋转的电影剪辑?,actionscript,rotation,Actionscript,Rotation,我有一个按钮(减少),当按下按钮时,箭头向左旋转。我需要箭头以一定角度停止(大约在8点钟) 如何获取箭头的角度,然后阻止它旋转超过此点(即使用户一直按下按钮) 这是我的密码: import flash.display.MovieClip; import flash.events.MouseEvent; import flash.events.Event; stop(); var rotate = 0; decrease.addEventListener(MouseEvent.MOUS
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
stop();
var rotate = 0;
decrease.addEventListener(MouseEvent.MOUSE_DOWN, decreasePressed);
decrease.addEventListener(MouseEvent.MOUSE_UP, removeEnterFrame);
function decreasePressed(e:MouseEvent):void
{
rotate = -2;
addEnterFrame();
}
function addEnterFrame():void
{
this.addEventListener(Event.ENTER_FRAME, update);
}
function removeEnterFrame(e:MouseEvent):void
{
this.removeEventListener(Event.ENTER_FRAME, update);
}
function update(e:Event):void
{
arrow1.rotation += rotate;
}
假设您的箭头是垂直创建的,且箭头指向上方,则逆时针旋转(如您所做)时的8点钟位置约为-112度。因此,您需要在更新方法中添加检查,以确保箭头的旋转未设置为低于-112的值:
// May need to adjust this depending on how your arrow is created
var minDegrees = -112;
function update(e:Event):void
{
var position:int = arrow1.rotation + rotate;
// Check increment of rotation does not take us past our limit
if (position <= minDegrees)
position = minDegrees;
arrow1.rotation = position;
}
//可能需要根据箭头的创建方式进行调整
var minDegrees=-112;
功能更新(e:事件):无效
{
变量位置:int=箭头1。旋转+旋转;
//检查旋转增量不会使我们超过极限
如果(位置)