In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flashTest00

easing test
Get Adobe Flash player
by HirakenCom 08 Mar 2012
    Embed
package {
    import flash.display.Sprite;
    import flash.events.Event;

    public class FlashTest extends Sprite {
        
        private var ball:Sprite;
        private var easing:Number = 0.1;
        private var vx:Number = 0.0;
        private var vy:Number = 0.0;
        private var g:Number = 0.9;
                
        public function FlashTest() {
            ball = makeBall();
            this.addChild(ball);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        private function makeBall():Sprite{
            var tempBall:Sprite = new Sprite();
            var posX:int = (Math.random() * 250) + (Math.random() * 250);
            var posY:int = (Math.random() * 250) + (Math.random() * 250);

            tempBall.graphics.beginFill(0x00FFFF);
            tempBall.graphics.drawCircle(0,0,10);
            return tempBall;
        }
        
        private function onEnterFrame(e:Event):void{
            var dx:int = (mouseX - ball.x) * easing;
            var dy:int = (mouseY - ball.y) * easing;
            
            vx += dx;
            vy += dy;
            vx *= g;
            vy *= g;
            
            ball.x += vx;
            ball.y += vy;
        }

    }
}