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

flash on 2011-9-9

Get Adobe Flash player
by antalg 10 Sep 2011
    Embed
/**
 * Copyright antalg ( http://wonderfl.net/user/antalg )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/jK2c
 */

package {
    import flash.text.TextField;
    import flash.events.KeyboardEvent;
    import flash.utils.IDataInput;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import com.actionsnippet.qbox.*    
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var container:MovieClip = new MovieClip();    
            stage.addChild(container);
            
            _world = new QuickBox2D(container);
            _world.createStageWalls();
            
            var count:int = 32;
            
            var dA:Number = 2*Math.PI/count;
            var i:int;
            for(i = 0; i<count; i++) {
                _balls.push( spawnBall(7+Math.cos(dA*i), 7+Math.sin(dA*i), 0.1) );
            }
            
            _ball = spawnBall(7, 7, 0.5);
             
            for(i = 0; i<count; i++) {
                _world.addJoint({type:"distance", a:_balls[i].body, b:_balls[(i+1)%count].body});
                _world.addJoint({type:"distance", a:_balls[i].body, b:_balls[(count/2+i)%count].body});
            }
 
            _world.start();
            _world.mouseDrag();
        }
        
        private var _world:QuickBox2D;
        private var _balls:Array = new Array();
        private var _ball:QuickObject;
        
        private function spawnBall(x:Number, y:Number, rad:Number):QuickObject {
            return _world.addCircle({x:x, y:y, radius:rad});
        }
    }
}