Author Archives: Zevan

Zig Zag Binary ix2 & i/2

CLICK HERE TO COPY
Actionscript:

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

txt.text = "";

txt.width = 190;

txt.height = 400;

txt.multiline = true;

 

var count:int = 1;

function render():void{

    var line = int(count).toString(2);

    while(line.length <31){

        line = "0" + line;

    }

    txt.appendText(line + "\n");

    txt.scrollV= txt.maxScrollV;

}

 

addEventListener(Event.ENTER_FRAME, onCountUp);

function onCountUp(evt:Event):void {

    count *= 2;

    render();

    [...]

Posted in Math, string manipulation, strings | Leave a comment

N to the power of N (with strings)

CLICK HERE TO COPY
Actionscript:

var input:String =  "a, b, c";

 

var words:Array = input.split(", ");

var max:String = "";

var maxD:String =  (words.length - 1).toString();

for (var i:int = 0; i<words.length; i++){

    max += maxD;

}

var maxInt:int = parseInt(max,words.length);

 

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

     var indices:String = i.toString(words.length);

     var r:String = "";

     var k:int=0;

     for (var j:int [...]

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

Tweetcoding

CLICK HERE TO COPY
Actionscript:

g=graphics;

mt=g.moveTo;

lt=g.lineTo;

ls=g.lineStyle;

m=Math;

r=m.random;

s=m.sin;

i=0;

o={};

function f(e){

    s=150,x=y=s,z=-s,c=(!i)?addChild(new Bitmap(new BitmapData(s,s))).bitmapData:c;while(i<22500)i++,c.setPixel(i%s,i/s,(i%s|i/s)*mouseX);i=1;

}

addEventListener("enterFrame",f);

Have to link to this very fun new contest:
http://tweetcoding.machine501.com/
http://gskinner.com/playpen/tweetcoding.html
I may just have to get a twitter account...

Posted in misc | Tagged , | Leave a comment

24hr Clock

CLICK HERE TO COPY
Actionscript:

var clock:Sprite = Sprite(addChild(new Sprite()));

clock.x = clock.y = 150;

 

var bg:Shape = Shape(clock.addChild(new Shape()));

with (bg.graphics) lineStyle(2, 0x666666), beginFill(0xEFEFEF), drawCircle(0,0,110);

 

var hHand:Shape = clockHand(6, 50);

var mHand:Shape = clockHand(2, 80);

var sHand:Shape = clockHand(1, 90);

 

var center:Shape = Shape(clock.addChild(new Shape()));

with (center.graphics) beginFill(0x000000), drawCircle(0,0,5);

 

var hInc:Number = 360/24;

var msInc:Number = 360/60 ;

var nOff:Number = 6;

var verdana:TextFormat = new TextFormat("Verdana", 8);

// [...]

Posted in misc | Tagged , | 4 Comments