# HELP PLEASE with mc movement

**URL:** <https://forum.kirupa.com/t/help-please-with-mc-movement/192948>\
**Category:** flash\
**Created:** [July 3, 2006, 3:49am UTC](https://forum.kirupa.com/t/help-please-with-mc-movement/192948 "2006-07-03T03:49:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![santalea](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@santalea](https://forum.kirupa.com/u/santalea)\
**Post date:** [July 3, 2006, 3:49am UTC](https://forum.kirupa.com/t/help-please-with-mc-movement/192948/1 "2006-07-03T03:49:15Z")

</div>

i added a button to the below codes. and when i click on the button it will only move from tarArray[70,120] to tarArray[80,215]. it will keep repeating that move instead of going to [110,270], 170,…  
can someone take a look at my codes and help me solve this mystery which is wrecking my brain. thankz…

================================================== ======

> 

var targetIndex:Number = 0;  
var tarArray:Array = [[70,120], [80,215], [110,270], [170,320], [225,280], [300,360], [355,430], [520,380], [610,500]];  
this.createEmptyMovieClip(“line\_mc”, 1); //creating the line  
this.attachMovie(“arrowmc”, “arrowmc”, this.getNextHighestDepth()); //inserting the mc  
line\_mc.lineStyle(2, 0xFF00FF, 30);  
line\_mc.moveTo(tarArray[0][0], tarArray[0][1]); // starting point of the target  
arrowmc.\_x = tarArray[0][0];  
arrowmc.\_y = tarArray[0][1];  
var move\_int = setInterval(moveChaser,50); //setting time delay between movements  
function moveChaser() {  
//works out the angle in radians between tarArray[targetIndex] and arrowmc  
var theta:Number = Math.atan2(tarArray[targetIndex][1] - arrowmc.\_y, tarArray[targetIndex][0] - arrowmc.\_x);  
//changes radians to degrees and orientates it 90 more degrees because in flash 0 degrees is facing right  
arrowmc.\_rotation = (theta \* 180 / Math.PI)+90;

//checks that tarArray[targetIndex] and arrowmc are more than 2 away from each other  
if(Math.abs((tarArray[targetIndex][0]-arrowmc.\_x)) \> 2 || Math.abs((tarArray[targetIndex][1]-arrowmc.\_y)) \> 2){  
//moves arrowmc 3 towards tarArray[targetIndex]  
arrowmc.\_x += Math.cos(theta) \* 3;  
arrowmc.\_y += Math.sin(theta) \* 3;  
//draws the line to wherever arrowmc is  
line\_mc.lineTo(arrowmc.\_x , arrowmc.\_y);  
}

route\_btn.onRelease = function(){  
//test for no more targets in tarArray  
if(tarArray[targetIndex][0] == undefined){  
clearInterval(move\_int);  
trace(“successful”);  
}  
//to go to the next Array  
targetIndex++;  
trace(“Target Index:” +targetIndex);  
}

route\_btn.addEventListener(“click”, moveChaser);  
};
