I'm about to begin on a project for work where a user has the ability to select areas on a map by clicking and dragging his mouse over and area. When the person is finished they will let go of the mouse button and a nice little square will appear on the map where they
have selected.

Just use onMouseDown and onMouseUp handlers for the movieclip that contains your map. Record the _xmouse and _ymouse at each event. Those are the diametric corners of your new selection. Here's a bit of pseudocode, which is not actionscript and won't work, but gives you the idea:

var startX, startY, endX, endY;

map.onMouseDown
{
   startX = _xmouse;
   startY = _ymouse;
}

map.onMouseUp
{
   endX = _xmouse;
   endY = _ymouse;
   drawSquare(startX, startY, endX, endY);
}

function drawSquare(startX, startY, endX, endY)
{
   var squareMC = new MovieClip("squareGraphic");
   squareMC._x = startX;
   squareMC._y = startY;
   squareMC._width = endX - startX;
   squareMC._height = endY - startY;
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to