2 Replies Latest reply on Sep 17, 2017 6:34 AM by pastorpixel

    localToGlobal responsive

    pastorpixel Level 1

      I have a problem with localToGlobal, by using the responsive publish Settings.

      In the stage there is a  Movieclip named "car" in this Movieclip ist a nested Movieclip named "wheel"

      I want to get the Position of wheel from the view of the stage, so my code is in the first frame of the stage


      var p = this.car.wheel.localToGlobal(0,0);


      This works fine if you dont publish with responsive size, and the canvas is in the upper left corner of the browser window.

      Can you help me?

        • 1. Re: localToGlobal responsive
          RandomlyFish Level 3

          The problem is that the values you get from localToGlobal are affected by the scaling of the stage, where as the position of objects are not. Here's a function that I wrote, which you can use instead of calling localToGlobal on a symbol.


          // The function
          function LocalToGlobal (_symbol) {
               var point = _symbol.localToGlobal(0, 0);
               // Makes the x and y values not affected by the responsive scaling
               point.x /= stage.scaleX;
               point.y /= stage.scaleY;
               return point;
          // Example
          var globalPosition = LocalToGlobal(this.mcParent.mcChild);
          this.mc.x = globalPosition.x;
          this.mc.y = globalPosition.y;
          • 2. Re: localToGlobal responsive
            pastorpixel Level 1

            Thank you very much :-)