hehe, nope!  You can either:
- make a new canvas for each of your arrows
OR
- make a "final draft" canvas that your mouseUp draws on, and a "drawing" 
canvas that your mouseMove draws on.  That way, when their mouse is 
released, the final arrow is drawn in the right place, while your drawing 
canvas you can clear to your hearts content, but never clear the final draft 
canvas.


----- Original Message ----- 
From: "Prasad Dhananjaya" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Thursday, September 22, 2005 2:13 AM
Subject: Re: [flexcoders] Question about "mouseMove"


Hi,

Thanks for your reply.

Now it's working. But still have a problem. I can't use clear(),
because it deletes all previously drawn arrows.
Any other way to do this with out deleting other arrows which are
on the canvas?

Thanks,

------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
var isPointerStarted = false;
var bx:Number;
var by:Number;

function mouseMoveHandler(event) {
if (!isPointerStarted) return;
★mycanvas1.clear();★
mycanvas1.lineStyle(1, 0xFF0000, 30);
     mycanvas1.createChild(drawingArrow());
updateAfterEvent();
}

function pointerStart() {
if (isPointerStarted) return;
isPointerStarted = true;
bx = mycanvas1.mouseX;
by = mycanvas1.mouseY;
}

function pointerReleased() {
if (!isPointerStarted) return;
mycanvas1.lineStyle(2.5, 0x666666, 100);
mycanvas1.createChild(drawingArrow());
isPointerStarted = false;
}

function drawingArrow(){
var w = mycanvas1.mouseX - bx;
var h = mycanvas1.mouseY - by;
var l = Math.sqrt(w * w + h * h);
var size=8;
var sharpness=0.5;
var s = Math.sin(sharpness);
var c = Math.cos(sharpness);

if(l>0 ){
w *= size / l;
h *= size / l;
mycanvas1.moveTo(bx,by);
mycanvas1.lineTo(mycanvas1.mouseX, mycanvas1.mouseY);
mycanvas1.lineTo(mycanvas1.mouseX - w * c - s * h, mycanvas1.mouseY + w * 
s - h * c);
mycanvas1.moveTo(mycanvas1.mouseX, mycanvas1.mouseY);
mycanvas1.lineTo(mycanvas1.mouseX - w * c + s * h, mycanvas1.mouseY - w * 
s - h * c);
}
}
]]>
</mx:Script>

  <mx:Canvas id="mycanvas1"
mouseDown="pointerStart()"
mouseUpSomewhere="pointerReleased()"
width="700" height="400"
borderStyle="solid"
backgroundColor="#DDEEFF"
backgroundAlpha="0"
mouseMove="mouseMoveHandler(event)">
  </mx:Canvas>
</mx:Application>

-------------------------------------------------
> You need to call your draw function via mouseMove, but have the drawing 
> algo
> clear() each time.  Additionally, add an updateAfterEvent() at the end of
> your function since mouseMoves can happen faster than the screen can 
> redraw.
> The mouseUp function will then call the same function, only once.
>
> ----- Original Message ----- 
> From: "Tracy Spratt" <[EMAIL PROTECTED]>
> To: <flexcoders@yahoogroups.com>
> Sent: Wednesday, September 21, 2005 12:34 PM
> Subject: RE: [flexcoders] Question about "mouseMove"
>
>
> I am not sure how to implement this or how this would affect your
> performance, but you probably need to use a doLater() to let the screen
> update.
>
> Tracy
>
> -----Original Message-----
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Prasad Dhananjaya
> Sent: Wednesday, September 21, 2005 7:21 AM
> To: FlexML
> Subject: [flexcoders] Question about "mouseMove"
>
> Hi,
>
> I have a small question about mouseMove action.
>
> Below code draws an arrow between mouseDown point and mouseUp point.
> It works well. But arrow displays only after mouseUp event.I want to
> display arrow during moving of mouse (before I do mouseUp).
> I think I have to add "something" to mouseMoveHandler().
> But didn't know what? Can someone tell me how can I do this?
>
> Thanks,
>




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to