Author Archives: Zevan

Fp10 3d Logo

CLICK HERE TO COPY
Actionscript:

var container:Sprite = new Sprite();

container.x = stage.stageWidth / 2;

container.y = stage.stageHeight / 2;

addChild(container);

 

var redBox:Sprite = new Sprite();

redBox.graphics.beginFill(0xFF0000);

redBox.graphics.drawRect(-50,-250,100,500);

redBox.rotationZ = 10;

container.addChild(redBox);

 

var logos:Array = []

var elements:Array = [];

elements.push({element:redBox, z:0});

 

// add the logos

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

    var logoContainer:MovieClip = new MovieClip();

    var logoText:TextField = new TextField();

    logoText.defaultTextFormat = new TextFormat("_sans", [...]

Posted in 3D, misc, motion | Tagged , , , | 1 Comment

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 , , | 4 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 , , , | 12 Comments

Paste Your Interface

Are you working on something right now that makes use of interfaces? Copy and paste an interface into the comments of this post (no need for code tags or anything)....
CLICK HERE TO COPY
Actionscript:

package app{

   

    import flash.events.IEventDispatcher;

   

    public interface IBaseModel extends IEventDispatcher{

       

        function [...]

Posted in OOP, misc | Tagged , , | 13 Comments

BitmapData Frame Texture

CLICK HERE TO COPY
Actionscript:

[SWF(width = 800, height = 600)]

var circle:Shape = new Shape();

var radius:Number = 4;

var diameter:Number = radius * 2;

var diam4:Number = diameter * 4;

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

circle.filters = [new BlurFilter(5, 5, 2)];

 

var currFrame:Frame;

 

// populate the linked list

generateAnimation();

 

var animationNum:int = 8000;

var animation:Vector.<Frame> = new Vector.<Frame>();

var locs:Vector.<Point> = new Vector.<Point>();

// populate locs and animation

while(animation.length <animationNum){

    [...]

Posted in BitmapData, Data Structures, Vector | 1 Comment

BitmapData Frame Animation (w/ linked list)

CLICK HERE TO COPY
Actionscript:

[SWF(width = 100, height = 100)]

var circle:Shape = new Shape();

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

 

var currFrame:Frame;

 

// populate the linked list

generateAnimation();

 

var canvas:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false, 0x000000);

addChild(new Bitmap(canvas));

var loc:Point = new Point(20, 20);

 

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

    // clear the canvas

    canvas.fillRect(canvas.rect, 0x000000);

    // draw the current frame

    canvas.copyPixels(currFrame.bitmap, currFrame.bitmap.rect, loc, null, null, true);

  [...]

Posted in BitmapData, Data Structures, misc, motion, pixel manipulation | Tagged , , | 1 Comment

Triangular Numbers

CLICK HERE TO COPY
Actionscript:

[SWF(width = 500, height = 500)]

 

var txt:TextField = TextField(addChild(new TextField()));

txt.defaultTextFormat = new TextFormat("_sans", 4);

txt.width = stage.stageWidth;

txt.height = stage.stageHeight+4;

txt.z = -1;

txt.x = stage.stageWidth

txt.rotation = 90;

var count:int = 0;

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void{

     count++;

     txt.appendText(triangular(count).toString(2) + "\n");

     txt.scrollV= txt.maxScrollV;

}

function triangular(n:int):int{

       return (n * (n + 1)) / 2;

}

Calculate some triangular numbers... [...]

Posted in Math, misc | Tagged , , | Leave a comment

Flowing Leaves (optical illusion)

Saw this optical illusion today... figured I'd make a snippet to create a few variations on the illusion...
CLICK HERE TO COPY
Actionscript:

[SWF( backgroundColor=0x2E7999, width=780, height = 600) ]

 

var leafNum:Number = 375;

var spacing:Number = 12;

var cols:Number = 25;

var hh:Number = stage.stageHeight / 2;

var hw:Number = stage.stageWidth / 2;

 

for (var i:Number = 0; i<leafNum; i++){

    var leaf:Shape [...]

Posted in Graphics, Math, Vector, misc, motion, pixel manipulation | Tagged , , , | 5 Comments