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: forked from: flash on 2009-5-20

Get Adobe Flash player
by onedayitwillmake 21 May 2009
    Embed
/**
 * Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eBRU
 */

// forked from little_dandy's forked from: flash on 2009-5-20
// forked from little_dandy's flash on 2009-5-20
package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Graphics;
    import flash.geom.Point;
    import flash.events.Event;
    import frocessing.FC;
    import frocessing.color.FColor;
    
     [SWF(frameRate="120", width="465", height="465", backgroundColor="#000000")] 
     
    public class FlashTest extends Sprite {
        
        private var sw:Number = stage.stageWidth;
        private var sh:Number = stage.stageHeight;
        private var cx:Number = sw/2;
        private var cy:Number = sh/2;
        private var shape:Shape;
        private var g:Graphics;
        private var ary:Array;
        private var cn:Number = Math.floor(Math.random()*9)+3;
        private var cDeg:Number = 360/cn;
        private var degree:Number = 0.;
        private var ragian:Number = 0.;
        
        private var numBlocks:int = 0;
    	private var startColor:int = 0;
    
        public function FlashTest() {
            // write as3 code here..
            init();
        }
        
        private function init():void
        {
            ary = new Array();
            var fpx:Number = Math.random()*cx;
            var fpy:Number = Math.random()*cy;
            var r:Number =  Math.pow(Math.pow(fpx-cx,2)+Math.pow(fpy-cy,2),0.5);
            var fDeg:Number = Math.atan2(fpy-cy,fpx-cx)*180/Math.PI;
            for (var i:int =0;i<cn;i++){
                var pRag:Number = (fDeg+cDeg*i)/180*Math.PI;
                var px:Number = r*Math.cos(pRag)+cx;
                var py:Number = r*Math.sin(pRag)+cy;
                var p:Point = new Point(px,py);
                ary.push(p);
            } 
            shape = new Shape();
            addChild(shape);
            g = shape.graphics;
            addEventListener(Event.ENTER_FRAME,upDate);
        }
        
        private function upDate(e:Event):void
        {
            startColor = (startColor + 3) % 360;
            
            var c:FColor = new FColor();
            	c.hsv(startColor, 1, 1);
            
            //g.clear();
            g.lineStyle(1, c.value, 0.1);
            ragian = (degree/180)*Math.PI;
            
            var opx:Number = 0;
            var opy:Number = 0;
            for(var i:int =0;i<cn;i++){
                var px:Number = ((ary[i].x-cx)*Math.cos(ragian)-(ary[i].y-cy)*Math.sin(ragian))+cx;
                var py:Number = ((ary[i].x-cx)*Math.sin(ragian)+(ary[i].y-cy)*Math.cos(ragian))+cy;
                ary[i].x = px;
                ary[i].y = py;
                if(i == 0){
                    g.moveTo(px,py);
                    opx = px;
                    opy = py;
                }else if(i != cn-1){
                    g.lineTo(px,py);
                }else{
                    g.lineTo(px,py);
                    g.lineTo(opx,opy);
                }
            }

            degree += 2;
            
            if(degree > 360){
                degree = 0;
                
                g.clear();
                

            }
        }
    }
}