2 Replies Latest reply on Jun 22, 2006 9:17 AM by >zero

    Programmatic movement problem

    >zero
      Completely baffled by this:

      I have an mc (of a map) which I want to move around to specific coordinates in x and y axes in response to button clicks.

      It does this very well using the following code:

      //in the firstframe of the main movie

      //loads the map swf
      loadMovieNum("testmap.swf",100);

      var startX = 0
      var startY = 0
      var speed = 10

      function moveMe(targ){
      targ._x+=(_root.endX-targ._x)/_root.speed
      targ._y+=(_root.endY-targ._y)/_root.speed
      }

      And then this code is on every button in the main move:

      on(release){

      gotoAndPlay("myFrameLabel");

      setInterval(moveMe,30,_level100.myMap)

      //target coordinates for the map to move to
      var endX = 290
      var endY = -30
      }

      This works perfectly, making the map slide from position to position 'easing out' every time - except that for some reason, each time you click on a button - the map moves to its new coordinates slighly faster, until it appears to jump directly to the next position.

      I can't see how it's doing it - I think the 'speed' variable is always the same, so perhaps the setInterval is decreasing to cause this effect?

      I'd welcome any ideas on this!