[ff] Simple Animation

by hemingway forked from Simple Animation (diff: 6)
example for Wataru on custom animations:
animation easing, or smoothing.

animates towards it's destination with a magnitude determined by the continuously smaller distance between object & destination; therefore the velocity is continuously smaller and produces an 'easing' behavior
♥0 | Line 24 | Modified 2013-04-16 02:36:46 | MIT License
play

ActionScript3 source code

/**
 * Copyright hemingway ( http://wonderfl.net/user/hemingway )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/k4MO
 */

// forked from Wataru.Miyazaki's Simple Animation
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.*;

    public class FlashTest extends Sprite {
        
        public var sampleView:Sprite;
        public var sampleDestination:Point;
        
        public function FlashTest() {
            // write as3 code here..
            
            sampleView = new Sprite();
            sampleView.graphics.lineStyle(10, 0x00aa00);
            sampleView.graphics.drawCircle(0, 0, 30);
            sampleDestination = new Point(100, 0);
            addChild(sampleView);
            
            addEventListener(Event.ENTER_FRAME, move);
            
        }
        
        private function move(e:Event):void {
         
            var sampleX:Number;
            sampleX = sampleView.x;
            if(sampleX<(sampleDestination.x-1)){ 
                 sampleView.x += (sampleDestination.x - sampleX)/8;
            }
            
        }
        
        
    }
}