Message Box

I am trying to create a talk key so that when pressed (space bar) if the “hero” is touching (hitTest) a NPC (townsfolk) a text box’s visibility is turned on and off. For instance, this is in the NPC’s code:

	onClipEvent(enterFrame){
 	if (this.hitTest(_root.hero)&& Key.isDown(Key.SPACE)){
 		_root.messagebox._visible= true;
 		_root.messagebox.message="Hey, fancy meeting you here!";
 		}
 }
 

I also coded the player’s movement to stop while the text box is visible. The main problem I am having is that I want to be able to press the space bar to “close” (visiblity off) the text box as well. However since the hero is still colliding with the NPC the text box just stays there. Any help would be greatly appreciated.