I was recently experimenting with different way to move a character in a flash game. I came to these conclusions using my own ideas, but I'm sure it's been done before.

Anyway, with your typical overhead flash game, you have only eight directions (arrow keys) and one speed (that is, if it's not dependant on a certain time of movement therefore simulating momentum) this is a bit of script that can be used for varying directions and speeds.

First, one used for single character movement, put on the main character itself.

onClipEvent (enterFrame) {
ydist = (this._y - _parent._ymouse)/20;
xdist = (this._x - _parent._xmouse)/25;
}

onClipEvent (enterFrame) {
this._y -= ydist;
this._x -= xdist;
}


Secondly, one used for a game where the character stays centered, but the background moves to simulate movement.

to be put on a background mc

onClipEvent (enterFrame) {
ydist = (200 - _parent._ymouse)/20;
xdist = (275 - _parent._xmouse)/25;
}

onClipEvent (enterFrame) {
if (_parent._ymouse < 139.0) {
this._y += ydist;
}
if (_parent._xmouse > 331.1) {
this._x += xdist;
}
if (_parent._ymouse > 258.0) {
this._y += ydist;
}
if (_parent._xmouse < 214.8) {
this._x += xdist;
}
}


I might post a few demos later if I can get them up online...

Anyway, like I said, this has probably been done before, but I just found this on my own, and I thought it was so cool that I'd share it.