4 Replies Latest reply on Jan 6, 2010 2:41 AM by seRajan

    Flex automation - need to capture the mousemove

    seRajan

      hi All,

       

           I am creating Whiteboard application. I want to test my application through automation, but i can't capture the mousemove event.

       

      Inside the Whiteboard i have drawing fucntionality, this functionality require the mousedown, mousemove and mouseup events. I need to capture these events.

       

      Please help me.

       

       

      - Rajan

        • 1. Re: Flex automation - need to capture the mousemove
          Claudino Bur

          Hello,

           

          Try Application.application.stage.addListener(MouseEvent.MOUSE_DOWN,mousedown_handler) which mousedown_handler is a function accepting a MouseEvent parameter.

          Look also at this example http://www.java2s.com/Code/Flash-Flex-ActionScript/Development/Addmouseupanddownlistener.h tm

           

          Claude Bur.

          • 2. Re: Flex automation - need to capture the mousemove
            seRajan Level 1

            Thank you for the replay.

             

            My requirement for Flex Automation.

             

            I added mouse listeners, but those events wants to record into automation.

             

             

            Please check this : http://www.adobe.com/devnet/flex/samples/custom_automated/

             

            currrently this sample file only capture the mouseclick event. I need to record other mouse listener also.

             

            - Rajan

            • 3. Re: Flex automation - need to capture the mousemove
              Claudino Bur Level 2

              Hello,

               

              Download customagent_src.zip and there you will find AutomationGenericEnv.xml. I see there 

                   <Event Name="MouseMove" >
                              <Implementation Class="flash.events::MouseEvent" Type="mouseMove"/>

                   <Event Name="Click" >
                               <Implementation Class="flash.events::MouseEvent" Type="click"/>

               

              As you can see only those 2 events click and mouseMove are registered for listening. Add your listeners there for example mouseUp, mouseDown etc.

               

              Claude Bur.

              • 4. Re: Flex automation - need to capture the mousemove
                seRajan Level 1

                I tryed that method.

                 

                 

                This is my sample file:

                 

                 

                <?xml version="1.0" encoding="utf-8"?>

                <mx:Application

                 

                 

                xmlns:mx="http://www.adobe.com/2006/mxml"

                applicationComplete="init();"

                >

                 

                 

                <mx:Script>

                <![CDATA[

                 

                 

                import mx.automation.Automation;

                 

                import mx.automation.IAutomationManager;

                 

                private function init():void

                {

                bindDraw.addEventListener(MouseEvent.MOUSE_DOWN, _MouseDownHandler,

                 

                false, 0, true);

                }

                 

                 

                private function _MouseDownHandler(evt:MouseEvent):void

                {

                 

                this.systemManager.addEventListener(MouseEvent.MOUSE_UP, _MouseUpHandler, false, 0, true);

                 

                bindDraw.addEventListener(MouseEvent.MOUSE_MOVE, _MouseMoveHanlder,

                false, 0, true);

                 

                bindDraw.graphics.lineStyle(3, 0, 1);

                 

                bindDraw.graphics.moveTo(evt.localX, evt.localY);

                }

                 

                 

                private function _MouseMoveHanlder(evt:MouseEvent):void

                {

                bindDraw.graphics.lineTo(evt.localX, evt.localY);

                }

                 

                 

                private function _MouseUpHandler(evt:MouseEvent):void

                {

                bindDraw.graphics.clear();

                 

                 

                this.systemManager.removeEventListener(MouseEvent.MOUSE_UP, _MouseUpHandler, false);

                 

                bindDraw.removeEventListener(MouseEvent.MOUSE_MOVE, _MouseMoveHanlder,

                false);

                }

                 

                 

                private var _count:Number = 0;

                 

                 

                private function clickHandler(evt:MouseEvent):void

                {

                evt.currentTarget.label=

                "clicked "+(++_count);

                }

                ]]>

                 

                </mx:Script>

                 

                <mx:Button id="b1" label="click me" click="clickHandler(event)"/>

                 

                <mx:Canvas showInAutomationHierarchy="true" id="bindDraw" width="100%" height="100%" />

                 

                <mx:Canvas id="fff" width="100" height="100" backgroundColor="34233"/>

                </mx:Application>