# setInterval inside a loop inside a function - Am I crazy?!

**URL:** https://forum.kirupa.com/t/setinterval-inside-a-loop-inside-a-function-am-i-crazy/276760
**Category:** flash
**Created:** [December 3, 2008, 11:23am UTC](https://forum.kirupa.com/t/setinterval-inside-a-loop-inside-a-function-am-i-crazy/276760 "2008-12-03T11:23:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ollywood](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@ollywood](https://forum.kirupa.com/u/ollywood)
#### Post date: [December 3, 2008, 11:23am UTC](https://forum.kirupa.com/t/setinterval-inside-a-loop-inside-a-function-am-i-crazy/276760/1 "2008-12-03T11:23:43Z")

</div>

I’ve got a menu loading from XML data - however I’d like the mc’s to appear sequentially, maybe 1/10th second apart. I know setInterval should do this, but I’m still new to flash and despite trawling Google for 24 hrs solid, nothing seems to show me the right way.

Here’s the script:

```auto

function CreatePortMenu(port_xml)
{
   var portClients = port_xml.firstChild.childNodes;
   var xPos = 0;
   var yPos = 0;
   var xSpacing:Number = 90;
   var ySpacing:Number = 35;
   var i = 0;
   
   for ( i = 0; i < portClients.length; i++ )
   {
      switch (i) //splits the menu items into columns of 4 (max 12 items)
      {
         case 0:
         case 1:
         case 2:
         case 3:
         yPos = ySpacing * i;
         break;
         case 4:
         case 5:
         case 6:
         case 7:
         xPos = xSpacing * 2;
         yPos = ySpacing * (i - 4);
         break;
         case 8:
         case 9:
         case 10:
         case 11:
         xPos = xSpacing * 3;
         yPos = ySpacing * (i - 8);
      }
      
      var currentClient = portClients*;
      
      var portHold = portHolder_mc.attachMovie( "jobOption", "pb"+i, i, {_x:xPos, _y:yPos});
      
      portHold.jobTitle.jobText.text = currentClient.attributes.title;
         
   }
      
}

```

So I _think_ I should be inserting two lines, one creating a setInterval, and one clearing it, but where? Some guides say inside the function, some say outside, some say only the clearInterval should be inside, some have the function inside the loop… I also _think_ I’ve tried every possible combination, but no soap. Please help!?
