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: LoadingFlower

これに影響されて作ったよ。
*
*  @see http://tirirenge.undo.jp/sample/fire.html
Get Adobe Flash player
by hacker_7i4tn9on 31 Mar 2009
// forked from hacker_7i4tn9on's forked from: LoadingFlower
// forked from soundkitchen's LoadingFlower
/**
 *  これに影響されて作ったよ。
 *
 *  @see http://tirirenge.undo.jp/sample/fire.html
 */
package
{
    import flash.display.BlendMode;
    import flash.display.Sprite;
    import flash.events.Event;

    [SWF(frameRate=30, width=465, height=465, backgroundColor=0x000000)]

    public class Main extends Sprite
    {
        public function Main()
        {
            addEventListener(Event.ADDED_TO_STAGE, initialize);
        }

        /**
         *  initialize the object.
         */
        private function initialize(evt:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, initialize);

            var i:uint,
                c:uint,
                l:Loading;
            for (i=0; i<30; i++)
            {
                c = Math.floor(Math.random() * 256) << 16
                  | Math.floor(Math.random() * 256) << 8
                  | Math.floor(Math.random() * 256);

                l = new Loading(
                    c,
                    Math.ceil(Math.random() * 10),
                    Math.ceil(Math.random() * 30),
                    Math.ceil(Math.random() * 30),
                    Math.ceil(Math.random() * 50)
                );
                //l.blendMode = BlendMode.INVERT;
                l.x = Math.floor(Math.random() * stage.stageWidth);
                l.y = Math.floor(Math.random() * stage.stageHeight);
                addChild(l);
            }
        }
    }
}

import flash.display.Shape;
import flash.events.Event;

class Loading extends Shape
{
    private var _color:uint;
    private var _needleWidth:Number;
    private var _needleLength:Number;
    private var _numNeedles:uint;
    private var _innerRadius:Number;

    public function Loading(color:uint=0x000000,
                            needleWidth:Number=3,
                            needleLength:Number=10,
                            numNeedles:uint=15,
                            innerRadius:Number=20)
    {
        _color = color;
        _needleWidth = needleWidth;
        _needleLength = needleLength;
        _numNeedles = numNeedles;
        _innerRadius = innerRadius;

        draw();

        addEventListener(Event.ADDED_TO_STAGE, initialize);
    }

    public function draw():void
    {
        var i:uint,
            cx:Number, cy:Number,
            cAngle:Number,
            nAngle:Number;

        cAngle = -Math.PI / 2;
        nAngle = Math.PI * 2 / _numNeedles;

        graphics.clear();
        for (i=0; i<_numNeedles; i++)
        {
            cAngle += nAngle;
            graphics.lineStyle(_needleWidth, _color, i/(_numNeedles - 1));
            cx = Math.cos(cAngle) * _innerRadius;
            cy = Math.sin(cAngle) * _innerRadius;
            graphics.moveTo(cx, cy);

            cx = cx + Math.cos(cAngle) * _needleLength;
            cy = cy + Math.sin(cAngle) * _needleLength;
            graphics.lineTo(cx, cy);
        }
    }

    private function initialize(evt:Event):void
    {
        removeEventListener(Event.ADDED_TO_STAGE, initialize);
        addEventListener(Event.REMOVED_FROM_STAGE, finalize);
        addEventListener(Event.ENTER_FRAME, step);
    }

    private function step(evt:Event):void
    {
        rotation = (rotation + 360 / stage.frameRate) % 360;
    }

    private function finalize(evt:Event):void
    {
        removeEventListener(Event.REMOVED_FROM_STAGE, finalize);
        removeEventListener(Event.ENTER_FRAME, step);
    }
}