Author Archives: Zevan

Fermat’s Spiral

CLICK HERE TO COPY
Actionscript:

x = stage.stageWidth / 2;

y = stage.stageHeight / 2;

 

var xp:Number = 0, yp:Number = 0;

var r:Number = 0, t:Number = 0;

var speed:Number = .07;

var scale:Number = 20;

 

var plot0:Shape = Shape(addChild(new Shape()));

var plot1:Shape = Shape(addChild(new Shape()));

plot0.graphics.lineStyle(0,0x000000);

plot1.graphics.lineStyle(0,0x000000);

 

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

     r =  scale * Math.sqrt(t);

     xp =  r * Math.cos(t);

     yp [...]

Posted in Graphics, Math, motion | Tagged , | Leave a comment

var obj:Object = new Function()

CLICK HERE TO COPY
Actionscript:

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

   

    var x:Number = xp;

    var y:Number = yp

   

    this.setX = function(v:int):void{

        x = v;

    }

    this.setY = function(v:int):void{

        y = v;

    }

    this.getX = function():int {

        return [...]

Posted in OOP, Object, functions | Tagged , | Leave a comment

Interesting Function Composition

CLICK HERE TO COPY
Actionscript:

var multBy2Add3:Function = add(3, mult(2));

 

trace(multBy2Add3(10));

// 10 * 2  = 20

//  20 + 3 = 23

 

var add2AndSquare = sq(add(2));

 

trace(add2AndSquare(8));

// 8 + 2 = 10

// 10 * 10 = 100

 

var multBy2_3times:Function = repeat(3,mult(2));

 

trace(multBy2_3times(3));

// 3 * 2 = 6;

// 6 * 2 = 12;

// 12 * 2 = 24

 

// you can also chain for even [...]

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

ActionScript Wiki

Just wanted to post a link to Joa Ebert's ActionScript Wiki. Looks like there's some great stuff there...

Posted in misc | Tagged , | Leave a comment