Flash Labs NO.1 : Famous Matrix Code- Binary

03Aug08

Today I finally started the experiments with Adobe Flash AS2 and here comes my first experiment.

All that’s needed is a black background and a movieclip called “code” exported for AS with a little green dynamic text area named “inside”.

Change the number of frames per second to 120 and copy this code to the first frame on the main timeline.


/* MATRIX BINARY CODE v. 0.1
You'll need: black background, movieclip "code" exported for AS, dynamic text "inside" inside the "code" movieclip
coder: Ranza
web: https://masteranza.wordpress.com
time: 00:09:26
*/

//function which varies the brightness
function setBrightness(col:Color, brightness:Number):Void {
    var anum:Number = 100 - brightness;
    var bnum:Number = 255 / 100 * brightness;
    col.setTransform( {ra:anum, ga:anum, ba:anum, rb:bnum, gb:bnum, bb:bnum, aa:100, ab:0} );
};

var colMin:Number = 0;        // min brightness
var colMax:Number = 50;        // max brightness
var colVariance:Number = colMax - colMin;
var chars:Array = ["0","1"]
var depth:Number = 0;
var lastx:Number=0;
var chainlen:Number=0;
var lastspeed:Number =0;

//function which randomizes color
function nooCol(Void):Number {
    return colMin + Math.random() * colVariance;
}

onEnterFrame = function(){
    if (Math.floor(Math.random() * 1) == 0) { //how often to create new movieclips
        depth++;
        var noo:MovieClip = _root.attachMovie("code", "code" + depth, depth);
        noo.inside.text = chars[Math.floor(Math.random()*chars.length)];
        var col:Color = new Color(noo);
        setBrightness(col, nooCol());
        //the part responsible for creating chains
        if (Math.floor(Math.random() * 10) == 0){
            noo._x = Math.random()*Stage.width;
            noo._y = -10;
            chainlen = 0;
            noo.speed = Math.random() * 3 + 1;
            lastspeed = noo.speed;
        }
        else{
            chainlen++;
            noo._x = lastx;
            noo._y = -10 - (noo._height*chainlen);
            noo.speed = lastspeed;
        }
        lastx = noo._x;
        noo.onEnterFrame = _root.flow;
    }
}
//this function which was handled the onEnterFrame event makes our code move
function flow(){
    this._y += this.speed;
    if (this._y > Stage.height) {
        this.removeMovieClip();
    }
}

Gosh… How big was my furry when I noticed that there’s no way to upload swf files and insert as2 sourcecode on wordpress.com … That’s why my code isn’t as colorful as it should be. Damn.



4 Responses to “Flash Labs NO.1 : Famous Matrix Code- Binary”

  1. vqirmwpz fjnm trykif hlfgw zvtp irpmbunwc qkdtgmrh

  2. 2 Nadya Fermega

    Oh boolen…, from pure mathematics to great applications.

  3. 3 Nadya Fermega

    After giving a question how to prove that 1 – 1 = 0 on a discussion forum at this address castingoutnines.wordpress.com/2008/12/10/leibniz-on-112/, now the discussion broads to the topics “how the concept of divinity plays into Leibniz et al ideas” in order to prove that 1 + 1 = 2.

    In the discussion one of the visitor gives definition of the 1 number as following

    1/2 + 1/(2^2) + 1/(2^3) + 1/(2^4) + . . .= 1

    I need your help, from which the origin of the above definition?

  4. Wonderful post! We will be linking to this particularly great content on our site.

    Keep up the good writing.


Leave a reply to Nadya Fermega Cancel reply