I need help with boundary/wall coding

Yo, I’m making a Flash RPG game on a very low ActionScript experience.
I don’t know what to do about my character going through walls or boundaries
that he’s not suppose to go to, such as the ocean.

I have made the ocean on a different layer. Is there anyway I could block the character from going on a certain layer? Or do yall have any other ideas?