How to make a "selection box"?

Hello everybody. This is my first post and i hope someone can help me.
I want to make a box that the user move by the mouse and it can select different objects. Similar when a box appear on a windows desktop if you want to select a set of files or folders.
I tried to do this using the release event, but i find out a surprise. That the box is drawn at the final of the event, when the user stop to press the mouse button. Maybe, i’m wrong respect the event to use. I put the following code on a big rectangle (the mc) which simulates a desktop space or something

  
on(press) 
{
 x=_xmouse+_x;
 y=_ymouse+_y;
}
on(release) 
{
_root.createEmptyMovieClip ("square", 1);
 with (_root.square){
 
  lineStyle (5, 0x000000, 100);
  moveTo (x,y);
  lineTo (_xmouse, y);
  lineTo (_xmouse, _ymouse);
  lineTo (x, _ymouse);
  lineTo (x,y);
 }
}

thanks for any advice