Help on holding a weapon

Hi, I have come to a problem in a game that I am making. I have started a simple side scroller where you can pick up multiple weapons on the map, and drop them as you please. The code is placed on each weapon and is in a movieclip seperate from the main character movieclip. The code is as follows:


onClipEvent (load) {
 held = false;
 count = 0;
}
onClipEvent (enterFrame) {
 if (this.hitTest(_root.p1hand)) {
  if (Key.isDown(Key.UP)) {
   held = true;
  }
 }
 if (Key.isDown(Key.DOWN)) {
  held = false;
 }
 if (held == true) {
  _x = _root.p1hand._x;
  _y = _root.p1hand._y;
  _yscale = _root.p1hand._yscale;
  _rotation = _root.p1hand._rotation;
  onMouseDown = function () {
   count++;
   _root.attachMovie("bullet", "bullet"+count, count);
  };
 }
}

“p1hand” is the movieclip of the hand that will hold the gun. The hand rotates around the caracter and the above code tells the gun to “stick” to the hand. To do this the hand touches the gun and if you press UP it is “held”. While held you can shoot the gun and aim in any direction until DOWN is pressed dropping the weapon. No physics have been applied so when you drop the gun it will just stay in the air. Thats no problem though I will fix it later. The problem I have is the gun will shoot event after you drop it. That is because of this part of the code:


onMouseDown = function () {
   count++;
   _root.attachMovie("bullet", "bullet"+count, count);
  };

I have never used functions before and I did it now because this is my first game using the mouse interactivity. I usualy make games that focus on keys but I like the way that this one plays. Because of the mouse I had to use “onMouseDown” to fire. I then realized that doesnt work so I had to do the function part. I think the function is causing a loop so that even when the weapon is not being held it still fires. It works until you grab and realease the gun, in which case the function is active an continues to fire. What I need is a way to stop the loop when the gun is released, when “held = false”. I havent done this before so I am a bit stuck, and I appreciate any help.