circleRound

by darman
♥0 | Line 26 | Modified 2009-07-22 14:34:18 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class CircleRound extends Sprite {
        
        private var _circle:Sprite;
        
        private var K:Number = 0.05;
        private var cx:Number = 200;
        private var cy:Number = 200;
        
        private var radius:Number = 50;
        private var center:Number = -radius / 2;

        public function CircleRound() {
            // write as3 code here..
            
            this._circle = new Sprite();
            this._circle.graphics.beginFill( 0xFF0000 );
            this._circle.graphics.drawCircle( 0,0,radius);
            this._circle.graphics.endFill();
            this.addChild( this._circle );
            
            this._circle.x = stage.stageWidth /2;
            this._circle.y = stage.stageHeight /2;
            
            this.addEventListener(Event.ENTER_FRAME, this._loop );
        }
        
        private function _loop(e:Event):void{

            this._circle.x -= ( this._circle.y - cy ) * K;
            this._circle.y += ( this._circle.x - cx ) * K;
        }
    }
}