setInterval?

I have some code to build a menu dynamically from an xml file.


var myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
    if (success) {
        buildMenu(myXML);
    }
};
function buildMenu(xml_doc) {
    currentWidth = 20;
    btnID = new Array();
    btnLabel = new Array();
    trace("building Menu");
    for (var n = 0; n<xml_doc.firstChild.childNodes.length; n++) {
        attachMovie("btn", "btn"+n, n+1);
        this["btn"+n].theText.autoSize = true;
        this["btn"+n].theText.text = xml_doc.firstChild.childNodes[n].attributes.btnLabel;
        this["btn"+n].bg._width = this["btn"+n].theText._width+16;
        this["btn"+n]._y = 0;
        this["btn"+n]._x = currentWidth;
        currentWidth += this["btn"+n].bg._width;
        // set the colour object for the button bg
        this["btn"+n].myCTO = new Object();
        this["btn"+n].myCTO.ra = 100;
        this["btn"+n].myCTO.rb = xml_doc.firstChild.childNodes[n].attributes.btnRed;
        this["btn"+n].myCTO.ga = 100;
        this["btn"+n].myCTO.gb = xml_doc.firstChild.childNodes[n].attributes.btnGreen;
        this["btn"+n].myCTO.ba = 100;
        this["btn"+n].myCTO.bb = xml_doc.firstChild.childNodes[n].attributes.btnBlue;
        this["btn"+n].myCTO.aa = 100;
        this["btn"+n].myCTO.ab = 255;
        // button functions
        this["btn"+n].onRollOver = function() {
            this.bg.colorTransformTo(this.myCTO, 0.2, "easeOutQuad");
        };
        this["btn"+n].onRollOut = function() {
            this.bg.colorTransformTo(100, 0, 100, 0, 100, 0, 0, 0, 0.2, "easeInQuad");
        };
        this["btn"+n].onRelease = function() {
            doNothing();
        };        
    }
}
myXML.load("topmenu.xml");

Which works fine, pulls in the attributes, label, colour and so on and builds the menu. However it hapens all at once as the for loop executes, how would I insert a pause so that the menu appears to build over time?

tia Project004

thanks claudio, i have used this and learnt all about setInterval, i posted elsewhere on this subject as i carried on with the project and used intervals quite extensively. I’m not sure I understand about the timing being independent from the timeline tho…

th again P