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: 再帰

Get Adobe Flash player
by 9re 01 May 2011
// forked from undo's 再帰
package {
    
    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.ui.Keyboard;

    [SWF(width='465', height='465', frameRate="30", backgroundColor='0x0')]
    public class ASTest extends Sprite{
        
        private var _childNum1:int = 4;
        private var _childNum2:int = 5;
        private var _color:uint = 0xaa4411;
        private var _objects:Vector.<Sprite> = new Vector.<Sprite>();
        
        public function ASTest() {
            init();
        }
        
        private function init():void
        {
            var w:Circle = addChild(new Circle(stage.stageWidth / 2, stage.stageWidth / 2, stage.stageWidth / 2, _color)) as Circle;
            _objects.push(w);
            makeChild(w, 1, stage.stageWidth / 2, _color);
            
            addEventListener(Event.ENTER_FRAME, onEnter);
        }
        
        private function makeChild(target:DisplayObjectContainer, index:int = 0, radius:Number = 100, color:uint = 0x0):void
        {
            var nPi:Number = Math.PI / _childNum2;
            var omega:Number = nPi * 2;
            var distance:Number = radius / (1 + Math.sin(nPi));
            radius *= Math.sin(nPi) / (1 + Math.sin(nPi));
            for(var i:int = 0; i < _childNum2; i++)
            {
                //var p:Point = new Point(Math.cos(omega * i) * (bradius - radius), Math.sin(omega * i) * (bradius - radius));
                var cx:Number = Math.cos(omega * i) * distance;
                var cy:Number = Math.sin(omega * i) * distance;
                var c:Circle = target.addChild(new Circle(cx, cy, radius, color)) as Circle;
                if(index < _childNum1)
                {
                    makeChild(c, index + 1, radius, color);
                }
                //c.addEventListener(Event.ENTER_FRAME, onEnter);
                _objects.push(c);
            }
        }
        
        private function onEnter(evt:Event):void
        {
            var len:int = _objects.length;
            for (var i:int = 0; i < len; ++i) {
                _objects[i].rotation += 0.2;
            }
        }
    }
}
import flash.display.Sprite;
import flash.events.Event;

class Circle extends Sprite
{
    private var _color:uint;
    private var _radius:Number;
    public function Circle(x:Number = 0, y:Number = 0, radius:Number = 100, color:uint = 0xffffff)
    {
        _radius = radius;
        _color = color;
        this.x = x;
        this.y = y;
        
        init();
    }
    public function init():void
    {
        this.graphics.lineStyle(1,_color);
        this.graphics.drawCircle(0,0,_radius);
    }
}