         if (m)
         {
             // Calculate the origin of the element after transformation before our changes are applied.
-            var origin:Point = new Point(measuredX,measuredY);
-            MatrixUtil.transformBounds(new Point(_width, _height), m, origin);
+            var topLeft:Point = computeTopLeft(new Point(measuredX, measuredY), _width, _height, m);
 
             // now adjust our tx/ty values based on the difference between our current transformed position and 
             // where we want to end up.
-            x = x - origin.x + layoutFeatures.layoutX;
-            y = y - origin.y + layoutFeatures.layoutY;
+            x = x - topLeft.x + layoutFeatures.layoutX;
+            y = y - topLeft.y + layoutFeatures.layoutY;
         }
         else
         {

        {
            // Calculate the vector from pre-transform top-left to
            // post-transform top-left:
            MatrixUtil.transformBounds(new Point(_width, _height), m, topLeft);
        }
        else
        {

////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2003-2006 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package mx.graphics.graphicsClasses
{
