AS2: stop my movieclip moving off stage

I have a movieclip moving around on key presses and I was wondering what is the best way to stop it moving off the stage?

I was thinking of putting hit tests around the edges but wondered if there was a better way?