4 Replies Latest reply on Jan 30, 2007 11:41 AM by Red Box New Media

    Help with slowing a for loop with setIterval

    Red Box New Media Level 1
      Hi all - any help with this would be much appreciated as I've been scratching my head all day on this one!

      I've got a Flash front end pulling in menu data from an XML file. It works out the number of duplicates of the empty menu item movie clip it needs, places them on the main stage, then populates the text field with the data from the XML file. All so far, so good. I'm trying to create interaction animation programmatically, (I want a menu item to slide to the right and change colour on rollOver and back again on rollOut), but having no luck.

      I can get the menu item to ping to the right using a for loop and I've tried every which way possible to stick a setInterval in there to try and slow the for loop down, but really not having any luck whatsoever. The code I started out with is:

      item_mc.onRollOut = currentThumb_mc.onDragOut = function(){
      for (var i = 0; i < 100; i++){
      this._x -= 1;
      }
      }


      and I've tried this, (and many other) variation to try and slow it all down:


      item_mc.onRollOut = currentThumb_mc.onDragOut = function(){
      for (var i = 0; i < 100; i++){
      this._x -= 1;
      moveItem = function () {
      doSomething();
      }
      itemMoverID = setInterval(moveItem, i+200000);
      }
      }

      But, as I said, I can't get it to work. Can anyone out there help me out ... please??

      Cheers
      A