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: [QuickBox2D] Soft Object #4

隣り合う丸は糸でつないで、天井の2点からゴムぶら下げた
/**
 * Copyright aobyrne ( http://wonderfl.net/user/aobyrne )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ovBn
 */

// forked from Kay's [QuickBox2D] Soft Object #4
// forked from Kay's [QuickBox2D] Soft Object #3
// forked from Kay's [QuickBox2D] Soft Object #2
// forked from Kay's forked from: QuickBox2D sample
// forked from mash's QuickBox2D sample
/*
 * 隣り合う丸は糸でつないで、天井の2点からゴムぶら下げた
 */
package {
    import flash.display.*;
    import com.actionsnippet.qbox.*;
    import flash.geom.*;
    import flash.events.*;

    public class FlashTest extends MovieClip {
            private const SW:Number = stage.stageWidth;
            private const SH:Number = stage.stageHeight;
        private const radius:Number = 1.2;
        private const outRadius:Number = 5;
        private const jHz:Number = 2;
        private const nColor:int = 0xff0000;
        private var outer:Array = new Array();
        private const dotNum:int = 12;
        private var sim:QuickBox2D;
        public function FlashTest() {
            sim = new QuickBox2D(this, { debug:true, gravityX:0, gravityY:0 });
            var anchorA:QuickObject = sim.addCircle({x:0,y:-SH/30,width:SH/30, radius:radius, density:0, fillAlpha:0, lineAlpha:0});
            var anchorB:QuickObject = sim.addCircle({x:SH/30,y:-SH/30,width:SH/30, radius:radius, density:0, fillAlpha:0, lineAlpha:0});
            var center:Point = new Point(SW/2/30, SH/2/30);
            // Outer
            for (var o:int = 0; o < dotNum; o++) {
                    var nR:Number = Math.PI*2/dotNum*o;
                var dot:QuickObject = sim.addCircle({
                    x:center.x+outRadius*Math.cos(nR), 
                    y:center.y+outRadius*Math.sin(nR), 
                    radius:radius, fillColor:0xcc9966, lineAlpha:0 });
                outer.push(dot);
                if (o > 0) {
                    sim.addJoint({a:outer[o-1].body, b:dot.body, lineAlpha:0});
                }
                sim.addJoint({a:dot.body, b:anchorA.body, frequencyHz:jHz, lineAlpha:0});
                sim.addJoint({a:dot.body, b:anchorB.body, frequencyHz:jHz, lineAlpha:0});
            }
            sim.addJoint({a:outer[dotNum-1].body, b:outer[0].body, frequencyHz:0, lineAlpha:0});
            for (o = 0; o < dotNum; o++) {
                    outer[o].y = 0;
            }
            
            sim.start();
            //sim.stop();    
            sim.mouseDrag();            
            scaleX=0.4;            
            scaleY=0.4; 
            y=210; 
            x=100;
            addEventListener(Event.ENTER_FRAME,loop);
        }
        private function loop(e:Event):void{removeEventListener(Event.ENTER_FRAME,loop);
        //sim.stop();
        }
    }
}