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,

---------------------------------------------------------------------
<?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 tmp_canvas:Object;
        var bx:Number=20;
        var by:Number=20;
        
        function mouseMoveHandler(event) {
                if (!isPointerStarted) return;                  
        }

        function pointerStart() {
                if (isPointerStarted) return;
                        isPointerStarted = true;
                        bx = mycanvas1.mouseX;
                        by = mycanvas1.mouseY;
        }
                
        function pointerReleased() {
                if (!isPointerStarted) return;
                                        mycanvas1.lineStyle(2, 0x000000, 100);
                                        var w = mycanvas1.mouseX - bx;
                                        var h = mycanvas1.mouseY - by;
                                        var l = Math.sqrt(w * w + h * h);
                                        var size=6;
                                        var sharpness=0.5;
                                        var s = Math.sin(sharpness);
                                        var c = Math.cos(sharpness);
                                        
                                        //Drawing arrow
                                        if (w>10 || h>10){
                                        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);
                                        }                               
                                        isPointerStarted = false;
        }
]]>
</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>




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/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