私は greensock tweenlite を使用して円形のムービークリップをクリック、ドラッグ、回転させていますが、これまでのところ次のようになっています。
私がする必要があるのは、回転の方向と速度を決定することです。つまり、ユーザーがホイールを右に回転させている場合、この方向を文字列変数に格納し、回転速度を数値変数に格納します。
mousestart と move 座標、および vinyl_mc 回転座標でさまざまなことを試しましたが、信頼できるものは何も得られません。方向と速度を決定し、これらを変数に格納する方法はありますか?
アプリはhttp://s46264.gridserver.com/dev/dave/rotate/rotate.htmlで表示でき 、ソース fla はhttp://s46264.gridserver.com/dev/dave/rotate/rotate にあります。これがまったく役立つ場合は、 fla.zip。
ありがとう。
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
import flash.events.*;
TweenPlugin.activate([ShortRotationPlugin]);
var oldRotation,ax,ay,bx,by,thetaA,thetaB,delTheta,newTheta:Number;
var direction:String;
function dragger(evt:MouseEvent)
{
if (evt.type == MouseEvent.MOUSE_DOWN)
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragger);
stage.addEventListener(MouseEvent.MOUSE_UP, dragger);
oldRotation = vinyl_mc.rotation;
ax = stage.mouseX - vinyl_mc.x;
ay = stage.mouseY - vinyl_mc.y;
thetaA = Math.atan2(ay,ax) * 180 / Math.PI;
if (thetaA < 0)
{
thetaA = - thetaA;
}
else
{
thetaA = 360 - thetaA;
}
}
else if (evt.type == MouseEvent.MOUSE_MOVE)
{
bx = stage.mouseX - vinyl_mc.x;
by = stage.mouseY - vinyl_mc.y;
thetaB = Math.atan2(by,bx) * 180 / Math.PI;
if (thetaB < 0)
{
thetaB = - thetaB;
}
else
{
thetaB = 360 - thetaB;
}
delTheta = thetaB - thetaA;
newTheta = oldRotation - delTheta;
TweenLite.to(vinyl_mc, 1, {shortRotation:{rotation:newTheta}, overwrite:true, ease:Cubic.easeOut});
}
else if (evt.type == MouseEvent.MOUSE_UP)
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragger);
stage.removeEventListener(MouseEvent.MOUSE_UP, dragger);
}
}
vinyl_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragger);