Author Archives: Zevan

Functions Returning Functions

CLICK HERE TO COPY
Actionscript:

var connect:Function = function(xp:Number, yp:Number, col:uint=0):Function{

    graphics.lineStyle(0,col);

    graphics.moveTo(xp, yp);

    var line:Function = function(xp:Number, yp:Number):Function{

        graphics.lineTo(xp, yp);

        return line;

    }

    return line;

}

 

// draw a triangle

connect(200,100)(300,300)(100,300)(200, 100);

 

// draw a box

connect(100,100, 0xFF0000)(150,100)(150,150)(100, 150)(100,100);

This is one of those techniques that I never really get tired [...]

Posted in functions, misc | Tagged , , | 6 Comments

QuickBox2D Custom Debug Draw

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Dynamics.*

 

stage.frameRate = 60;

 

var sim:QuickBox2D = new QuickBox2D(this, {debug:true});

 

// get at the b2DebugDraw instance

var debug:b2DebugDraw = sim.w.m_debugDraw;

debug.m_drawScale = 30.0;

debug.m_fillAlpha = 0.5;

debug.m_alpha = 0.5;

debug.m_lineThickness = 1.0;

debug.m_drawFlags = 0xFF;

 

sim.createStageWalls();  

 

for (var i:int = 0; i<10; i++){

  sim.addBox({x:3 + i, y:3 + i, width:2, height:0.5});

}

sim.addCircle({x:12, y:5, radius:2});

 

sim.start();

sim.mouseDrag();

Note: This snippet requires the QuickBox2D library
This snippet [...]

Posted in Uncategorized | Tagged , , , , | 2 Comments

Obfuscated Slider

CLICK HERE TO COPY
Actionscript:

var slider:MovieClip = makeSlider();

slider.addEventListener(Event.CHANGE, function(evt:Event):void{

    trace(evt.currentTarget.percent);                                  

});

 

function makeSlider():MovieClip{

    var slider:MovieClip = MovieClip(addChild(new MovieClip()));

    var circle:Sprite = Sprite(slider.addChild(new Sprite()));

    with (circle.graphics) beginFill(0x000000), drawCircle(0,0,10);

    var line:Shape = Shape(slider.addChild(new Shape()));

    with (line.graphics) [...]

Posted in UI | Tagged , , | Comments closed

QuickBox2D 1.1 (2 major bug fixes)

Since the release of QuickBox2D 1.0 two bugs were discovered by numerous developers. The first bug was the inability to properly destroy group objects. The second bug was a small memory leak that caused most QuickObjects to remain in memory. Both of these bugs are now resolved.
Download QuickBox2D 1.1
Testing the memory leak. In QuickBox2D 1.0 [...]

Posted in Box2D, QuickBox2D, motion, pixel manipulation | Tagged , , , | 25 Comments