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

[1日1Wonderfl]6日目: Circle から ドーナツへ

1日1Wonderfl 6/30日目
まずはポコポコ丸が出てくるトコロまで。
// forked from ahchang's forked from: forked from: forked from: forked from: とりあえずCircleを描いてみた
// forked from ahchang's forked from: forked from: forked from: とりあえずCircleを描いてみた
// forked from ahchang's forked from: forked from: とりあえずCircleを描いてみた
// forked from soundkitchen's forked from: とりあえずCircleを描いてみた
// forked from ahchang's とりあえずCircleを描いてみた
// 1日1Wonderfl 6/30日目
/**
 *  まずはポコポコ丸が出てくるトコロまで。
 */
package
{
    import flash.display.BlendMode;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    import com.flashdynamix.utils.SWFProfiler;

    import frocessing.color.ColorHSV;

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

    public class CircleBasic extends Sprite
    {
        public static const NUM_CIRCLES:uint = 150;
        public static const CIRCLE_RADIUS:Number = 150;
        public static const TIMER_DURATION:uint = 100;

        private var timer:Timer;
        private var centerX:Number;
        private var centerY:Number;
        private var cAngle:Number;
        private var nAngle:Number;
        private var halfRadius:Number;
        private var hsv:ColorHSV;

        public function CircleBasic()
        {
            init();
        }

        private function init():void
        {
            centerX = stage.stageWidth>>1;
            centerY = stage.stageHeight>>1;
            cAngle = 0;
            nAngle = Math.PI * 2 / NUM_CIRCLES;
            halfRadius = CIRCLE_RADIUS>>1;
            hsv = new ColorHSV(0, 1, 1, 1);

            SWFProfiler.init(this);

            timer = new Timer(TIMER_DURATION, NUM_CIRCLES);
            timer.addEventListener(TimerEvent.TIMER, timerHandler);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
            timer.start();
        }

        private function timerHandler(evt:TimerEvent):void
        {
            var sp:Shape, g:Graphics;

            sp = new Shape();
            sp.x = centerX + Math.cos(cAngle) * halfRadius;
            sp.y = centerY + Math.sin(cAngle) * halfRadius;
            sp.blendMode = BlendMode.LIGHTEN;

            hsv.h = cAngle / Math.PI * 180;

            g = sp.graphics;
            g.lineStyle(1, hsv.value, hsv.a);
            g.drawCircle(0, 0, CIRCLE_RADIUS);

            addChild(sp);

            cAngle += nAngle;
        }

        private function timerCompleteHandler(evt:TimerEvent):void
        {
            if (timer.running) timer.stop();

            timer.removeEventListener(TimerEvent.TIMER, timerHandler);
            timer.removeEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
        }
    }
}