It's probably worth noting that your class doesn't allow drawing a
square from bottom right to top left... An easy fix tho :-)

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of jensen.axel
Sent: 22 October 2007 16:16
To: [email protected]
Subject: [flexcoders] Re: Draw a straight line with your mouse

 

thanks for the help

here is the finished stuff.

http://axel.cfwebtools.com/index.cfm/2007/10/22/Drawing-in-Flex-using-th
e-UIComponent-part-2-note-dynamic-classes-too
<http://axel.cfwebtools.com/index.cfm/2007/10/22/Drawing-in-Flex-using-t
he-UIComponent-part-2-note-dynamic-classes-too> 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> 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:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of jensen.axel
> Sent: Friday, October 19, 2007 11:36 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> 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>
<mailto:flexcoders%40yahoogroups.com>
> , "jensen.axel" <axel@> 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
> >
>

 

Reply via email to