I’ve got this code for RTS-like movement in flash, but its AS3. I only know AS2, so i would be very thankful if any of you took your time to translate this to work on a movieclip.
[COLOR=#330099]var iswalking = false;[/COLOR]
var goX = char.x;
var goY = char.y;
var movespeed = 5;
var dir = "down";
stage.addEventListener(Event.ENTER_FRAME, loop);
function loop(Event){
if (iswalking == true) {
char.w.play();
} else {
char.w.gotoAndStop(1);
}
char.gotoAndStop(dir);
if ((goY-movespeed)>char.y) {
char.y += movespeed; dir = "down";
} else if ((goY+movespeed)<char.y) {
char.y -= movespeed; dir = "up";
} if ((goX-movespeed)>char.x) {
char.x += movespeed; dir = "right";
} else if ((goX+movespeed)<char.x) {
char.x -= movespeed; dir = "left";
} if ((goY-movespeed)>char.y || (goY+movespeed)<char.y || (goX-movespeed)>char.x || (goX+movespeed)<char.x){ iswalking = true;
} else {
iswalking=false
}
}
stage.addEventListener(MouseEvent.CLICK, setposition);
function setposition(MouseEvent){
goX=mouseX
[COLOR=#330099] goY=mouseY
}[/COLOR]
This is the code.
-lolz666