Loading Issues

I’m trying to determine if something is loaded or not and when it is I want it to run a function. If you take a look at the last part of my code you will see what I am trying to do. I am not in need of a preloader I just need to know when it is loaded so I can successfully apply a mask.

Thanks for any help you can give,
Saveth


var link_array:Array = [];
var cover_array:Array = [];

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        var total:Number = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            link_array* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            cover_array* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            _root.createEmptyMovieClip("covers"+i, i);
            cover_mc = _root["covers"+i];
            cover_mc.loadMovie(_root.cover_array*);
            cover_mc._x = 86*i;
            cover_mc._y = 0;
            _root.createEmptyMovieClip("mirror"+i, i+5);
            mirror_mc = _root["mirror"+i];
            mirror_mc.loadMovie(_root.cover_array*);
            mirror_mc._x = 86*i;
            mirror_mc._y = 168;
            mirror_mc._yscale = -100;
            gradient_mc.duplicateMovieClip("gradient"+i, i+10);
            gradient_mc = _root["gradient"+i];
            gradient_mc._x = 86*i;
            gradient_mc._y = 168;
            button_mc.duplicateMovieClip("button"+i, i+20);
            button_mc = _root["button"+i];
            button_mc._x = 86*i;
            button_mc._y = 0;
            button_mc.theLink = link_array*;
            button_mc.onRelease = function() {
                getURL(this.theLink, _blank);
            }
        }
    } else {
        content = "file not loaded!";
    }
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("playlist.xml");

for (a=0; a<5; a++) {
    _root["mirror"+a].onLoadComplete = function() {
        _root["mirror"+a].cacheAsBitmap = true;
        _root["gradient"+a].cacheAsBitmap = true;
        _root["mirror"+a].setMask("gradient"+a);
    }
}

(Flash 8 Compatible Only)

Well, I figured it out after reading up a little more on the MovieClipLoader class. Here is the completed code if anyone is interested.

This application is a graphical playlist generator. It will display the covers of certain cd’s that are pulled from the xml and then it will flip that cover vertically and apply a mask to it to give it a reflection. Each cover has a link to a certain itunes reference. It looks the best on a black background.


var link_array:Array = [];
var cover_array:Array = [];
var mirror_mcl:MovieClipLoader = new MovieClipLoader();
var loaderListener:Object = new Object();

loaderListener.onLoadInit = function() {
    for(a=0; a<5; a++) {
        _root["mirror"+a].cacheAsBitmap = true;
        _root["gradient"+a].cacheAsBitmap = true;
        _root["mirror"+a].setMask("gradient"+a);
        _root["mirror"+a]._visible = true;
        _root["gradient"+a]._visible = true;
    }
};

mirror_mcl.addListener(loaderListener);

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        var total:Number = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            link_array* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            cover_array* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            _root.createEmptyMovieClip("covers"+i, i);
            cover_mc = _root["covers"+i];
            cover_mc.loadMovie(_root.cover_array*);
            cover_mc._x = 86*i;
            cover_mc._y = 0;
            _root.createEmptyMovieClip("mirror"+i, i+5);
            _root["mirror"+i]._visible = false;
            mirror_mcl.loadClip(_root.cover_array*, "mirror"+i);
            _root["mirror"+i]._x = 86*i;
            _root["mirror"+i]._y = 168;
            _root["mirror"+i]._yscale = -100;
            gradient_mc.duplicateMovieClip("gradient"+i, i+10);
            gradient_mc = _root["gradient"+i];
            _root["gradient"+i]._visible = false;
            gradient_mc._x = 86*i;
            gradient_mc._y = 168;
            button_mc.duplicateMovieClip("button"+i, i+20);
            button_mc = _root["button"+i];
            button_mc._x = 86*i;
            button_mc._y = 0;
            button_mc.theLink = link_array*;
            button_mc.onRelease = function() {
                getURL(this.theLink, _blank);
            }
        }
    } else {
        content = "file not loaded!";
    }
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("playlist.xml");