Math

This code is for a square transition effect…the squares fade from top to bottom and are opaque. I have some actionscript and it works, it’s just too slow and I was wondering where in the code I’d change a variable to speed it up a bit.


function drawGrid(theWidth:Number, theHeight:Number, imageClip:MovieClip):Void {
    var initDot = new Object();
    var k:Number = 0;
    // Create a mask clip to hold all the dots
    this.createEmptyMovieClip("mask", 1);
    // Assign it as the masking clip
    imageClip.setMask(mask);
    for (var i:Number = 0; i<theWidth; i += 20) {
        for (var j:Number = 0; j<theHeight; j += 20) {
            var dotName:String = "dot"+i+"_"+j;
            initDot._x = i;
            initDot._y = j;
            initDot.timer = Math.ceil(Math.random( )*800)+(((initDot._y+(initDot._x/20))*1)/1);
            // Place the masking dots within the container mask clip
            mask.attachMovie("dot", dotName, k, initDot);
            k++;
        }
    }
}
drawGrid(900, 600, image1_mc);