Well, if you have rectangle walls, you can check if the character collides each side of the rectangle, for example if the character collides the top side of the rectangle you can set the vertical speed to 0 or you can use a while loop like this: while(player collide rectangle top){ player.y++; }
Remember that this only works for rectangles. I hope this helps you
Ups, I forgot to tell how the code works... If the player collides the rectangle top the loop gonna repeat until the player dont collide with the rectangle top, to stop the loop you need to decrement player.y until the player dont collide with the rectangle top.
A simple way is to use hiTestObject and have four different directional hit-zones. If the character moves into the "Left" hit-zone then it's does X to prevent the character to move through the left wall. It's not the best system but it's pretty easy to make.