Some more easing curves and another approach....
// Quadratic Bezier tween from b to b+c, influenced by p // t: current time, b: beginning value, c: total change, d: duration // p: Bezier control point position function tweenQuadBez (t, b, c, d, p):Number { return ((t/=d)*c + 2*(1-t)*(p-b))*t + b; }; // Quadratic Bezier tween from b to b+c, passing through p // t: current time, b: beginning value, c: total change, d: duration // p: point to pass through at halftime function tweenQuadBezThru (t, b, c, d, p):Number { return ((t/=d)*c + 2*(1-t)*(2*p-b-.5*c-b))*t + b; }; // Cubic Bezier tween from b to b+c, influenced by p1 & p2 // t: current time, b: beginning value, c: total change, d: duration // p1, p2: Bezier control point positions function tweenCubicBez (t, b, c, d, p1, p2):Number { return ((t/=d)*t*c + 3*(1-t)*(t*(p2-b) + (1-t)*(p1-b)))*t + b; }; function update() { var per = _xmouse/Stage.width; var ny = tweenQuadBez ( per, 0, (y2-y1), 1, (yp-y1) ) + y1; var nx = tweenQuadBez ( per, 0, (x2-x1), 1, (xp-x1) ) + x1; circle_mc._y = ny; circle_mc._x = nx; } function INIT() { Stage.align = 'TL'; Stage.scaleMode = 'noScale'; x1 = 50; y1 = 50; xp = 100; yp = 50; x2 = 300; y2 = 200; // CURVE this.createEmptyMovieClip("curve_mc", this.getNextHighestDepth()); curve_mc.lineStyle(0, 0x333333, 80); curve_mc.moveTo( x1, y1 ); curve_mc.curveTo( xp, yp, x2, y2); // CIRCLE var radius = 5; circle_mc = this.createEmptyMovieClip("circle_mc", this.getNextHighestDepth() ); circle_mc.lineStyle(0, 0x000000); drawCircle(circle_mc, 0, 0, radius); onMouseMove = update; } INIT(); function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void { mc.moveTo(x+r, y); mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y); mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, -Math.sin(Math.PI/4)*r+y); mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y); } _____________________________ Jesse Graupmann www.jessegraupmann.com www.justgooddesign.com/blog/ _____________________________ _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com