7 Replies Latest reply on Dec 22, 2006 3:04 PM by kglad

    dynamically build onEnterframe function

    MatMaar
      Hi

      I was wondering how to build dynamically onEnterframe functions.
      I want that my first onEnterframe() uses the values of the first time the for loop runs, the second onEnterframe uses the values build in the second time the for loop runs, the third time, ......

      What my script does now is that is all my items eventualy uses the last values that where build the last time the for loop has ran?

      I hope all this is clear enough for you guys.



      Here's my scrip tI use:
      function setNewImagePosition(){
      for(i=0; i<_root.myArray12Length; i++){
      speed = 4;
      whichNumber = _root.myArray12 ;
      whichNumber = whichNumber.substr(1,1);
      var p:Number = whichNumber;
      trace("whichNumber: " + p);
      myWidth = this["ImageMenuItem"+(p-1)]._width;

      var E:Number = (80+myWidth+(i*20));

      this["ImageMenuItem"+(p-1)].onEnterFrame = function(){
      this._x += (E-this._x)/speed;
      }
      }
      }