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)

もっとまるっこくしたいねん。
Get Adobe Flash player
by ProjectNya 24 Jan 2011
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mfHt
 */

////////////////////////////////////////////////////////////////////////////////
// もじゃもじゃ (1)
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.utils.Timer;
    import flash.events.TimerEvent;

    [SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var timer:Timer;
        private static var interval:uint = 100;
        private static var radius:uint = 2;
        private var circle:Shape;
        private static var color:uint = 0x000000;
        private static var xPos:uint = 232;
        private static var yPos:uint = 232;
        private static var range:uint = 40;
        private static var radian:Number = Math.PI/180;

        public function Main() {
            //Wonderfl.capture_delay(1);
            init();
        }

        private function init():void {
            circle = new Shape();
            addChild(circle);
            circle.x = xPos;
            circle.y = yPos;
            //
            start();
        }
        private function reset():void {
            circle.graphics.lineStyle(1, color);
            circle.graphics.moveTo(0, 0);
        }
        private function clear():void {
            circle.graphics.clear();
        }
        public function start():void {
            reset();
            addEventListener(Event.ENTER_FRAME, draw, false, 0, true);
            timer = new Timer(interval);
            timer.addEventListener(TimerEvent.TIMER, shake, false, 0, true);
            timer.start();
        }
        public function stop():void {
            clear();
            removeEventListener(Event.ENTER_FRAME, draw);
            if (timer) {
                timer.stop();
                timer.removeEventListener(TimerEvent.TIMER, shake);
            }
        }
        private function draw(evt:Event):void {
            var a1:Number = Math.random()*360;
            var r1:Number = Math.random();
            var x1:Number = Math.cos(a1)*range*r1;
            var y1:Number = Math.sin(a1)*range*r1;
            var a2:Number = Math.random()*360;
            var r2:Number = Math.random();
            var x2:Number = Math.cos(a2)*range*r2;
            var y2:Number = Math.sin(a2)*range*r2;
            circle.graphics.curveTo(x1, y1, x2, y2);
        }
        private function shake(evt:TimerEvent):void {
            var count:uint = evt.target.currentCount;
            if (count%40 == 0) {
                clear();
                reset();
            }
            circle.x = xPos + int(Math.random()*radius*2 - radius);
            circle.y = yPos + int(Math.random()*radius*2 - radius);
        }
        
    }

}