This movie requires Flash Player 9
Das Skript bewegt einen MovieClip entlang einer Bezier-Kurve. Die Knotenpunkte (Ankerpunkte) der Bewegung können als Array angegeben werden. Ich benutze die ZigoEngine um ein sanftes Beschleunigen und Abbremsen zu machen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import com.mosesSupposes.fuse.*; ZigoEngine.simpleSetup(PennerEasing, Shortcuts); gCounter = {cnt:0}; ZigoEngine.doTween ( gCounter, "cnt", 100, 5, 'easeInOutQuint', 0, {updFunc:update_position} ); function update_position () { var f = gCounter.cnt; var obj = bezier_curve_point( [[90,300], [120,130], [370,300], [430,60]], f, 100 ); ball_mc._x = obj.x; ball_mc._y = obj.y; } function bezier_curve_point ( pt, c, d ) { var a = 1-1/d*c; var b = 1-a; return {x:pt[0][0]*(a*a*a) + pt[1][0]*3*(a*a)*b + pt[2][0]*3*a*b*b + pt[3][0]*b*b*b, y:pt[0][1]*(a*a*a) + pt[1][1]*3*(a*a)*b + pt[2][1]*3*a*b*b + pt[3][1]*b*b*b } } |