Yeah, here's a couple tips that I found come in handy. Really really useful.
I'm assuming your walls are a rectangle, width the instance point (little crosshairs) in the exact center of it.
Also, for this to work, you're gonna need to seperate your walls into seperate MC's, just go into the mc and add _root.walls.push(this);
And then you just go through a for loop of the walls array and check each one ;).
If you don't want to, at least read through this, maybe something 'll be helpful.
Instead of just adding to the _y. Add to the yvel.
Make an xvel and yvel var (since your using onClipEvents do it onClipEvent(load) ).
Set em to 0.
And set them to 0 as the very first lines of your onClipEvent(enterFrame).
Now everytime you want to move the player when the user presses a key, just do something like this.xvel += this.RUN;
And then for the walls, you wouldn't just test this._x, you would do this._x+this.xvel .
This of course assumes you test AFTER you check for keys, otherwise xvel will always be 0.
And then if you hit, then xvel = 0; and this._x = Wall._x + Whatever# to put you on the side.
You could check if you're like going left or right, just have a dir variable that you set to 1 or -1 depending on if you press Key.LEFT or Key.RIGHT.
You also need to have a 'w' variable, it stands for width, so when your player is in it's idle frame, what it's width? If you take the width at the current frame, his running animation might make him wider and then skinnier through the animation, making it jittery. So keep that initial width and it'll make things smoother.
So
if(HitTest Code)
{
if(this.dir == 1)
{
this.xvel = 0;
this._x = _root.Wall._x-_root.Wall._width/2-this.w/2;
}
else
{
this.xvel = 0;
this._x = _root.Wall._x+_root.Wall._width/+-this.w/2;
}
}
It's not very complicated, very easy once you get the hang of it, and sooo useful. Makes things much smoother.