Not sure what to call this problem

Basically, decided to start playing around with AS again in Flash.

Coded a Movieclip to move on key down, tried a hitTest and both work.

(I’m using If/Else statements for these two).

My problem is, how can I combine both so I can tell the object to not move on key down once it hits another object.

Hope thats a good enough explaination.