title: Object isn't added in the right place, despite correct coordinates
body: <p>I have created a program in Actionscript 3 (Flash CS5) that spawns an Egg (a circle for now) off the stage when you click, and then sends the Egg to where you clicked with a (coded) tween. Additionally, it scales it in attempt to give an illusion of 3D.</p>
  
  <p>I add a TweenEvent.MOTION_FINISH to one of the tweens for the Egg, to check when the motion finishes. When it does, I create a new object (called Splat) with the same coordinates as the original mouse click.</p>
  
  <p><strong>Problem 1:</strong> The Splat object isn't added in the correct spot, as seen in the picture below. I check the coordinates, and they match in both the Egg class and the Splash class. I have also made sure that the registration point for both objects is in the middle of them. Finally, I have checked to see if it was the scale that made the problem, but I get the same problem even if I remove the scale tweens.</p>
  
  <p>(EDIT: The Egg is placed in the right spot. The original coordinates for the mouse click are as they should be. It is ONLY the star objects that seem to be displaced.)</p>
  
  <p><a href="http://i45.tinypic.com/24bj1h3.png" rel="nofollow">http://i45.tinypic.com/24bj1h3.png</a></p>
  
  <p><strong>Problem 2:</strong> The Splat object is scaled down the same amount as the Egg object. Why is this? I haven't (intended to) make the Splash dependent on the Egg.</p>
  
  <p>And here is the relevant code:</p>
  
  <pre><code>package  
  {
  import flash.display.MovieClip;
  import flash.utils.Timer;
  import flash.events.MouseEvent;
  
  public class eggMain extends MovieClip
  {
      import flash.events.Event;
  
      public function eggMain() 
      {
          stage.addEventListener(MouseEvent.CLICK, spawn);
      }
  
      function spawn(event)
      {
          for(var i:int = 0; i&lt;1; i++)
          {
              trace("mX in main class = " + mouseX);
              trace("mY in main class = " + mouseY);
              var e:Egg = new Egg(mouseX, mouseY);
              addChild(e);
  
          }
      }
  }
  }
  
  
  package  
  {
  import flash.display.MovieClip;
  import fl.transitions.Tween;
  import fl.transitions.easing.*;
  import fl.transitions.TweenEvent;
  
  
  public class Egg extends MovieClip 
  {
      var stageWidth:int = 550;
      var stageHeight:int = 400;
      var buffer:int = 100;
      var mX = 0;
      var mY = 0;
  
      public function Egg(moX:int, moY:int) //mouseX, mouseY
      {
          mX = moX;
          mY = moY;
          trace("mX in Egg constructor: " + mX);
          trace("mY in Egg constructor: " + mY);
  
          spawnAtFixedPoint();
          animate();
      }
  
  
  
  
      function spawnAtFixedPoint()
      {
          this.x = stageWidth + buffer;
          this.y = stageHeight - buffer;
      }
  
      //Moves the egg in from the spawn point using tweens. Scales down on the way to give 3D illusion.
      function animate()
      {
          var xMovement:Tween;
          var yMovement:Tween;
          var xScale:Tween;
          var yScale:Tween;
  
          trace("mX in animate() = " + mX);
          trace("mY in animate() = " + mY);
          xMovement = new Tween(this, "x", Regular.easeOut, this.x, mX, 1, true); //obj, property, ease function, start, time, in seconds (true)
          yMovement = new Tween(this, "y", Regular.easeOut, this.y, mY, 1, true);
          xScale = new Tween(this, "scaleX", Regular.easeIn, 1, 0.1, 1, true);
          yScale = new Tween(this, "scaleY", Regular.easeIn, 1, 0.1, 1, true);
  
  
          //Checks when the object has finished animating (which mean the egg has landed)
          xMovement.addEventListener(TweenEvent.MOTION_FINISH, splat);
      }
  
      //Spawns a splat (currently a star) at the same coordinates as the egg
      function splat(event)
      {
          trace("mX in splat() = " + mX);
          trace("mY in splat() = " + mY);
          var s = new Splat(mX, mY);
          addChild(s);
      }
  
  }
  }
  </code></pre>
  
  <p><strong>Update</strong>: 
  I created a custom SplatEvent and had my main class listen for it. The even is dispatched in the MOTION_FINISHED handler. It works!</p>
  
  <p>Although, I had to make it work by using public static vars in the main class for passing back the original coordinates of the Egg landing. Like so in the main class:</p>
  
  <pre><code>public static var splatX:int;
  public static var splatY:int;
  </code></pre>
  
  <p>And like this in the Egg class:</p>
  
  <pre><code>eggMain.splatX = mX;
  eggMain.splatY = mY;
  </code></pre>
  
  <p>I can live with it, but I would prefer not to use global variables. Taking suggestions for this, although the main question is answered. Thanks.</p>