Author Archives: Zevan

Mouse.cursor

CLICK HERE TO COPY
Actionscript:

var count:int = 0;

var cursors:Array = [MouseCursor.ARROW, MouseCursor.BUTTON, MouseCursor.HAND, MouseCursor.IBEAM];

setInterval(changeMouse, 100);

function changeMouse():void{

    Mouse.cursor = cursors[count % cursors.length];

    count++;

}

This is a small snippet that shows the cursor property of the Mouse class. This is fp10 only...

Posted in UI | Tagged , | Leave a comment

sine cosine Gradient

CLICK HERE TO COPY
Actionscript:

[SWF(width=600,height=500,frameRate=30)]

var canvas:BitmapData=new BitmapData(600,500,false,0x000000);

addChild(new Bitmap(canvas));

var size:Number=canvas.width*canvas.height;

var w:Number=canvas.width;

var wd:Number=1/w;

var pix:Vector.<uint> = new Vector.<uint>();

var sin:Number;

var cos:Number;

var dx:Number=110;

var dy:Number=52;

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

    dx+=0.001;

    canvas.lock();

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

        var xp:Number=i%w;

        var yp:Number=int(i*wd);

        var xx:Number=xp*0.05+dx;

        var yy:Number=yp*0.05+dy;

    [...]

Posted in BitmapData, Vector, graphics algorithms, pixel manipulation | 3 Comments

QuickBox2D Play

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*;

 

[SWF (backgroundColor=0xaa0000, width=700, height=600)]

 

const TWO_PI:Number = Math.PI * 2;

 

var sim:QuickBox2D = new QuickBox2D(this,{gravityY:20, debug:false});

 

var i:int = 0;

 

// add some circles

var circles:Array = [];

var circleNum:int = 20;

for (i = 0; i<circleNum; i++){

    circles[i] = sim.addCircle({x: 8, y:-2 - i, radius:0.1 + Math.random()*0.4, fillColor:0x000000});

}

 

// add some boxes

var boxes:Array = [];

var boxNum:int [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , | 1 Comment

Quick UI Creation (Brainstorming)

CLICK HERE TO COPY
Actionscript:

var ui:QuickUI = new QuickUI();

ui.x = 20;

ui.y = 260;

ui.addEventListener(Event.CHANGE, onChange);

addChild(ui);

 

var spriteA:Sprite = makeSprite(150,150,0xFF0000);

spriteA.addEventListener(MouseEvent.CLICK, onShowAddProps);

 

var spriteB:Sprite = makeSprite(350,150, 0xCC6600);

spriteB.addEventListener(MouseEvent.CLICK, onShowExcludeProps);

 

var spriteC:Sprite = makeSprite(550,150, 0x550066);

spriteC.addEventListener(MouseEvent.CLICK, onShowExcludeProps);

 

function onChange(evt:Event):void{

    // updates the property on the current target object

    ui.updateObject(evt.target);

}

function onShowAddProps(evt:MouseEvent):void{

    ui.rows = 3;

    // onle show the following properties

    //  add(property, [...]

Posted in UI, dynamic | Tagged , | 4 Comments