Using Trigonometry : Springs : Animation Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Animation » Springs »

 

Using Trigonometry


 

package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Main extends Sprite {
        private var _sprite:Sprite;
        private var _angle:Number = 45;
        private var _radius:Number = 200;
        
        public function Main(  ) {
            _sprite = new Sprite(  );
            _sprite.graphics.beginFill(0x0000ff100);
            _sprite.graphics.drawCircle(005);
            _sprite.graphics.endFill(  );
            _sprite.x = 0;
            _sprite.y = 100;
            addChild(_sprite);
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        public function onEnterFrame(event:Event):void {
            _sprite.x = 200 + Math.sin(_angle* _radius;
            _angle += .05;
        }
    }    
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Animation
» Springs