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

Box2D

Box2D
Get Adobe Flash player
by _perfect 21 Oct 2010

    Talk

    IQAndreas at 22 Oct 2010 15:12
    That's odd. Are you having trouble with the code, or are they meant to resize like that? Are you getting the same effect just using plain Box2D?

    Tags

    Embed
package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import com.actionsnippet.qbox.*;
    import Box2D.Common.Math.*;
    import flash.events.Event;
    import flash.media.Video;
    public class FlashTest extends MovieClip {
            private var con:QuickContacts;
            private var boxA:QuickObject;
            private var boxB:QuickObject;
            private var sim:QuickBox2D;
            
        public function FlashTest() {
            // write as3 code here..
            sim=new QuickBox2D(this);
            sim.createStageWalls();
            
            boxA=sim.addBox({x:1,y:1,width:1,height:1,fillColor:0xff5566});
            boxB=sim.addBox({x:1,y:1,width:1,height:1,fillColor:0x00ff00});
            boxA.userData.width=20;
            boxA.userData.height=20;
            boxB.userData.width=20;
            boxB.userData.height=20;
            
            sim.start();
            sim.mouseDrag();
            
            //接触判定のためのQuickContactを作成
            con=sim.addContactListener();
            con.addEventListener(QuickContacts.ADD,onAdd);
            con.addEventListener(QuickContacts.REMOVE,onRemove);
        }
       
        private function onRemove(e:Event):void{
            if(con.isCurrentContact(boxA,boxB)){
                boxA.userData.width=20;
                boxA.userData.height=20;
                boxB.userData.width=20;
                boxB.userData.height=20;
                }
            }
        private function onAdd(e:Event):void{
            if(con.isCurrentContact(boxA,boxB)){
                boxA.userData.width=20;
                boxA.userData.height=20;
                boxB.userData.width=20;
                boxB.userData.height=20;
                }
            }
    }
}