Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-27308

MouseEvent properties stageX, and stageY gets modified when moving a UI component from a MouseEvent.MOVE event handler

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK Previous
    • None
    • Spark: Application
    • None
    • Affected OS(s): Mac
      Affected OS(s): Mac OS 10.6
      Browser: Safari
      Language Found: English

    Description

      Steps to reproduce:

      1. Run the code pasted bellow. Inspect event.stageX and event.stageY at the lines where I've added the comments.

      Actual Results:
      The events properties stageX and stageY has been modified with the amount I moved my UI component

      Expected Results:
      The event properties should hold the values set at the time when the event was dispatched.

      Workaround (if any):
      Copy the stageX and stageY values before moving the UI Component.

      Example application:

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

      <s:Application minHeight="600" minWidth="955" xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">

      <fx:Script><![CDATA[

      //--------------------------------------------------------------------------------------------------
      //
      // IMPLEMENTATION
      //
      //--------------------------------------------------------------------------------------------------

      //------------------------------------------------
      // Fields
      //------------------------------------------------

      private var $$$xStart:Number = 0;

      private var $$$yStart:Number = 0;

      //------------------------------------------------
      // Functions
      //------------------------------------------------

      protected function $$$rect_mouseUpHandler( event:MouseEvent ):void

      { this.removeEventListener( MouseEvent.MOUSE_MOVE , handleMouseMove , false ); }

      protected function group1_mouseDownHandler( event:MouseEvent ):void

      { this.addEventListener( MouseEvent.MOUSE_MOVE , handleMouseMove , false , 0 , true ); $$$xStart = event.stageX; $$$yStart = event.stageY; }

      protected function handleMouseMove( event:MouseEvent ):void

      { var $deltaX:Number = event.stageX - $$$xStart; var $deltaY:Number = event.stageY - $$$yStart; $$$xStart = event.stageX; $$$yStart = event.stageY; $$$rect.x = $$$rect.x + $deltaX; $$$rect.y = $$$rect.y + $deltaY; // event.stageX is now event.stageX + $deltaX!!. Expected just event.stageX. // event.stageX is now event.stageY + $deltaY!!. Expected just event.stageY. event.updateAfterEvent(); }

      ]]
      ></fx:Script>

      <s:Group height="50" id="$$$rect" mouseDown="group1_mouseDownHandler(event)" mouseUp="$$$rect_mouseUpHandler(event)" width="50">

      <s:Rect height="50" width="50">

      <s:fill>

      <s:SolidColor color="#464646"/>

      </s:fill>

      </s:Rect>

      </s:Group>

      </s:Application>

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: