# setInterval?

**URL:** <https://forum.kirupa.com/t/setinterval/188052>\
**Category:** Uncategorized\
**Created:** [May 4, 2006, 4:39am UTC](https://forum.kirupa.com/t/setinterval/188052 "2006-05-04T04:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Project004](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@Project004](https://forum.kirupa.com/u/Project004)\
**Post date:** [May 4, 2006, 4:39am UTC](https://forum.kirupa.com/t/setinterval/188052/1 "2006-05-04T04:39:24Z")

</div>

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

```auto

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

---

<div class="post-metadata">

**Author:** ![Project004](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@Project004](https://forum.kirupa.com/u/Project004)\
**Post date:** [June 6, 2006, 6:45pm UTC](https://forum.kirupa.com/t/setinterval/188052/2 "2006-06-06T18:45:30Z")

</div>

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
