home > AS3でカスタムイージング
AS3でカスタムイージング
October 18, 2008
AS3でカスタムイージングを使う時は下記のfromCurve関数を設定すればOK。
private const _sample_array:Array = [{Mx:0,My:0,Nx:0,Ny:8,Px:10,Py:-83},
{Mx:10,My:-75,Nx:26,Ny:-238,Px:17,Py:206},{Mx:53,My:-107,Nx:62,Ny:186,Px:-21,Py:-195},
{Mx:94,My:-116,Nx:22,Ny:-202,Px:20,Py:175},{Mx:136,My:-143,Nx:54,Ny:156,Px:-18,Py:-174},
{Mx:172,My:-161,Nx:14,Ny:-94,Px:14,Py:55},{Mx:200, My:-200}];〜
Tweener.addTween(SampleMC, {y:0, time:5, transition:fromCurve,transitionParams: _sample_array});
〜
function fromCurve (t:Number,b:Number,c:Number,d:Number,pl:Array):Number {
var r:Number = 200 * t/d;
var i:Number = -1;
var e:Object;
while (pl[++i].Mx<=r) e = pl[i];
var Px:Number = e.Px;
var Nx:Number = e.Nx;
var s:Number = (Px==0) ? -(e.Mx-r)/Nx : (-Nx+Math.sqrt(Nx*Nx-4*Px*(e.Mx-r)))/(2*Px);
return (b-c*((e.My+e.Ny*s+e.Py*s*s)/200));
}