flash on 2011-2-15

by heroboy
♥0 | Line 40 | Modified 2011-02-15 18:46:17 | MIT License
play

ActionScript3 source code

/**
 * Copyright heroboy ( http://wonderfl.net/user/heroboy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mklu
 */

package {
    import flash.text.TextField;
    import flash.events.KeyboardEvent;
    import flash.display.*;
    import com.actionsnippet.qbox.*;
    import flash.ui.KeyLocation;AVM1Movie
    import Box2D.Common.Math.*;
    public class FlashTest extends MovieClip {
        private var _box:QuickObject;
        private var _text:TextField = new TextField();
        public function FlashTest() {
            
            // write as3 code here..
            stage.frameRate = 60;
            var sim:QuickBox2D = new QuickBox2D(this,{
               gravityY:0 
            });
            sim.createStageWalls();
            _box = sim.addBox({x:5, y:5, width:1, height:1,
            linearDamping:1,
            angularDamping:1
            
            });
            sim.addCircle({x:4, y:8, radius:2});
            sim.start();
            sim.mouseDrag();
            stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown,false);
            //addEventListener(KeyboradEvent.KEY_UP,onKeyUp,false);
            _text.height = stage.stageHeight;
            addChild(_text);
            
        }
        private function onKeyDown(e:KeyboardEvent):void
        {
            if (e.keyCode == 38)
            {
                _box.body.ApplyForce(new b2Vec2(0,-5),_box.body.GetPosition());
                _text.appendText("aaa\n");
            }

        
        }
        private function onKeyUp(e:KeyboardEvent):void
        {
            
        }


    }
}