2 Replies Latest reply on May 15, 2010 9:23 AM by jfillman

    Scale, stage.y and mouseY

    jfillman Level 1

      I have a scale function like this:

       

       

       

      private function runScale():void {

      myScale.scaleYFrom = origScaleYFrom;

      myScale.scaleYTo = myScale.scaleYFrom + (mySlider.value - previousValue);

      myScale.target = myContainer;

      myScale.autoCenterTransform =

      true;

      myScale.play();

      origScaleYFrom = origScaleYFrom + (mySlider.value - previousValue);

      previousValue = mySlider.value;

      }

       

      The scale runs and sizes things as expected.

       

      I have a script to resize visual elements on the screen like this:

       

      resizingElement.height = resizingElement.height + event.stageY - initY;

       

      This works perfectly when no scale factor has been applied to the container, however, after applying the scale, the mouse cursor get's seperated from the element I am resizing. The further I drag to resize, the further the gap between the cursor and the item. If I move the mouse back up, the cusor gets closer to the element, eventually going the other direction further away from the bottom of the element.

       

      So I traced the height change of the item being resized and the event.stageY value change, and they are identical. However, this.mouseY is NOT the same. This suggests that the stageY values is correctly calculating in the scale factor, but the mouseY is moving on the screen as if no scale has been applied.

       

      So is this a bug, or do I somehow need to be compensating for the scale factor? If so, how?

        • 1. Re: Scale, stage.y and mouseY
          TeotiGraphix Level 3

          Hi,

           

          Without seeing the full code I would say you have to multiply the calculated height by the scale factor applied, this will acount for the difference you are seeing with the mouse.

           

          resizingElement.height
           = (resizingElement.height + event.stageY - initY) * resizingElement.scaleY;
          

           

          Mike

          1 person found this helpful
          • 2. Re: Scale, stage.y and mouseY
            jfillman Level 1

            Hi Mike,

             

            Thank you for the reply. I do see the need to factor in the scale factor, but I still am working on the exact way to calculate it.

             

            First, I have to look at the scale factor for the container, not the element. The element itself has a scale factor of 1 since the scale effect was applied to the container.

             

            Second, since the scale factor is already accounted for in the event.stageY - initY portion of the equation, multiplying it by the scaleY value doesn't work correctly.

             

            JF