Author Archives: Zevan

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 , , | 14 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