Complex preloader

Hello all,

I’m working on a complex preloader, and I am just diving into the world of Actionscript, and I need some help. :slight_smile:

Basically, 0.66666% loaded (of my main movie), I want one of 150 movieclips (called pixelMovie - there’s just one of them in my library with linkage) to attach and then be moved (by the Tween Class) to a specific spot on my stage.

I have almost everything worked out (including where each pixel will go when its corresponding function is called) , except for the array, and some way of getting the percent loaded to initiate each tween function.

For the array, I don’t want to use up the space and memory to type out 150 of these:

pixels[0] = "1"
pixels[1] = "2"
.....
pixels[149] = "150"

I’ve looked, but couldn’t find a way to just assign the values for the array more simply.

Also, I need a way to get, for example, pixel1 to move to X:0 and Y:0 when my main movie is 0.6666% loaded. As you can see, I just have it worked out for pixel1 to move into its appropriate spot as of now.

Here’s my code so far: :blush:


pixels = new Array();
pixels.length = 100;
//Assign array values here.
//E.g., pixels[0] = "1"   pixels[1] = "2"   pixels[2] = "3" .... pixels[149] = "150"

//Declare variables.    
this.onEnterFrame = function() {
    var effectorNumber = Math.round(Math.random()*(1)+1);
};
var pixelNumber = 1;
var pixelSize = 50;
var pixelHoriSpan = stageWidth/cellSize;
var pixelVertSpan = stageLength/cellSize;
var stageWidth = 750;
var stageHeight = 750;
var begin = Math.round(Math.random()*(-50-(50)));
var time = 10;
var timeVariant = false;
var newMCName = pixels;
var bytesLoaded = ???.getBytesLoaded();
var bytesTotal = ???.getBytesTotal();

//I want to have this function initiated by every incremental percent loaded;
//e.g., if my main movie is 1% loaded, do this function for pixel number one (pixel1).
someButton.onRelease = function() {
    _root.container.attachMovie("pixelMovie", pixel1, this.getNextHighestDepth());
    determineTweenVariables();
    pixelNumber = 1;
};

function pixelTween() {
    var movieClip = _root.container.pixel1;
    var easeType = mx.transitions.easing.Regular.easeIn;
    determineTweenVariables(pixelNumber);
    goPixelGo = new mx.transitions.Tween(movieClip, effector, easeType, begin, end, time, timeVariant);
}
function determineTweenVariables() {
    if (effectorNumber == 1) {
        effector = "_x";
    }
    if (effectorNumber == 2) {
        effector = "_y";
    }
    if (effector == "_x") {
        if (pixelNumber<=pixelHoriSpan) {
            end = pixelSize*pixelNumber-pixelSize;
        }
        if (pixelNumber>pixelHoriSpan) {
            end = pixelSize*pixelNumber-((Math.ceil(pixelNumber/pixelHoriSpan)-1)*(stageWidth))-pixelSize;
        }
    }
    if (effector == "_y") {
        if (pixelNumber<=pixelVertSpan) {
            end = pixelSize*pixelNumber-pixelSize;
        }
        if (pixelNumber>pixelVertSpan) {
            end = pixelSize*pixelNumber-((Math.ceil(pixelNumber/pixelVertSpan)-1)*(stageHeight))-pixelSize;
        }
    }
}


Thanks a bunch!