我有一个使用旋转 TransformGestureEvent 顺时针旋转 120 度和逆时针旋转 120 度的表盘。
旋转此转盘时,我希望它控制影片剪辑。在顺时针旋转拨盘时拖动影片剪辑,然后在逆时针旋转拨盘时反转影片剪辑。我希望影片剪辑跟随拨盘的拖动,在拖动拨盘时停止和开始。
这是我到目前为止所拥有的,但它似乎只是将影片剪辑转到最后一帧然后停止?
import flash.display.MovieClip;
var dial_mc:MovieClip;
var knobs_mc:MovieClip;
var maxRotation:Number = 120;
var knobFrame:int = knobs_mc.currentFrame;
var offset:Number = 0;
var percent:Number = 0;
knobs_mc.stop();
Multitouch.inputMode = MultitouchInputMode.GESTURE;
dial_mc.addEventListener(TransformGestureEvent.GESTURE_ROTATE, rotateDial);
function rotateDial(e:TransformGestureEvent):void
{
dial_mc.rotation += e.rotation;
if (dial_mc.rotation > maxRotation)
{
dial_mc.rotation = maxRotation;
}
if (dial_mc.rotation < 0)
{
dial_mc.rotation = 0;
}
dial_mc.addEventListener(TransformGestureEvent.GESTURE_ROTATE, drag);
offset = e.rotation;
if (e.phase == GesturePhase.END)
{
knobFrame = knobs_mc.currentFrame;
}
function drag(e:TransformGestureEvent):void
{
percent = (e.rotation - offset)/knobs_mc.rotation;
var frame:int = Math.round(percent * knobs_mc.totalFrames) + knobFrame;
while (frame > knobs_mc.totalFrames)
{
frame -= knobs_mc.totalFrames;
}
while (frame <= 0)
{
frame += knobs_mc.totalFrames;
}
knobs_mc.gotoAndStop(frame);
}
}