Should be something like:
class LineDragging extends UIComponent
{
var startX:Number;
var startY:Number;
function mouseDownHandler(event:MouseEvent):void
{
startX = event.localX;
startY = event.localY;
addEventListener(MouseEvent.MOUSE_MOVE,
mouseMoveHandler, true);
}
function mouseMoveHandler(event:MouseEvent):void
{
graphics.clear();
graphics.lineTo(startX, startY);
var pt:Point = new Point(event.stageX,
event.stageY);
pt = globalToLocal(pt);
graphics.moveTo(pt.x, pt.y);
}
}
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of jensen.axel
Sent: Friday, October 19, 2007 11:36 AM
To: [email protected]
Subject: [flexcoders] Re: Draw a straight line with your mouse
please help... any links at all would help.
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "jensen.axel" <[EMAIL PROTECTED]> wrote:
>
> Hey,
>
> I need a little help, i've found some resources online on how to draw
> with your mouse, and most of them are like drawing with the pencil in
> any normal graphics programs... but i need to be able to have the user
> draw a straight line...
>
> when you mouseDown, that is the start point of the line...
>
> while your dragging the end of the line stays glued to your mouseX &
> mouseY till you mouseUp...
>
> I'm doing this extending a uicomponent... but having trouble finding
> good resources for this particular straight line type of use case...
>
> any help or links to get me pointed in the right direction would help
> tremendously.
>
> Thank you.
> Axel
>