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

forked from: Simple Circle anim

Get Adobe Flash player
by bradsedito 04 Jun 2011
/**
 * Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kjO9
 */

// forked from IPFix's Simple Circle anim
// forked from 883108's Sin and Cosin Wave
package {
    import flash.display.AVM1Movie;
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class Circle extends Sprite {
        private var angle:Number = Math.PI;
        private var centerX:Number = stage.stageWidth/2;
        private var centerY:Number = stage.stageHeight/2;
        private var radius:Number = 50;
        private var speed:Number = -Math.PI*2/100;
        private var circleMask:Sprite;
        
    public function Circle():void 
    {    
         addEventListener(Event.ENTER_FRAME, init); 
        
        function init():void 
        {         
            var circlePerfect:Sprite = new Sprite();
            circlePerfect.graphics.beginFill(0xFAFAFA);
            circlePerfect.graphics.lineStyle(3, 0xCCCCCC);
            circlePerfect.graphics.drawCircle(centerX,centerY,radius-3);
            circlePerfect.graphics.endFill();
            
            addChild(circlePerfect);
            
            circleMask = new Sprite();
            
            circleMask.graphics.beginFill(0xFAFAFA);
            circleMask.graphics.lineStyle(6, 0xCCCCCC); 
            circleMask.graphics.moveTo(centerX,centerY);
            addChild(circleMask);
            circlePerfect.mask = circleMask;
                
            addEventListener(Event.ENTER_FRAME, onEnterFrame);   
             
            circleMask.graphics.lineTo(centerX + Math.sin(angle) * radius, centerY + Math.cos(angle) * radius);
            angle += speed;           
        }
    }        
        private function onEnterFrame(e:Event):void{
                circleMask.graphics.lineTo(centerX + Math.sin(angle) * radius, centerY + Math.cos(angle) * radius);
                addEventListener(Event.ENTER_FRAME, init);
                if(angle<-Math.PI){
                    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
                }
//                else
 //               {
  //                  addEventListener(Event.ENTER_FRAME, onEnterFrame);
   //             }

                angle += speed;
        }
    }
}