 import flash.display.NativeWindowDisplayState;
 import flash.events.Event;
 import flash.events.MouseEvent;
-import flash.events.NativeWindowDisplayStateEvent;
 import flash.geom.Rectangle;
 import flash.system.Capabilities;
 import flash.text.TextFormat;
 import flash.text.TextFormatAlign;
+
 import mx.controls.Button;
-import mx.core.WindowedApplication;
 import mx.core.IFlexDisplayObject;
 import mx.core.IUITextField;
 import mx.core.IWindow;
-import mx.core.mx_internal;
 import mx.core.UIComponent;
 import mx.core.UITextField;
-import mx.styles.CSSStyleDeclaration;
+import mx.core.mx_internal;
 import mx.styles.ISimpleStyleClient;
 import mx.styles.IStyleClient;
-import mx.styles.StyleManager;
 
 use namespace mx_internal;
 

        else // titleAlign is center
        {
            var tf:TextFormat = new TextFormat();
            tf.align = TextFormatAlign.CENTER;
            titleTextField.setTextFormat(tf);

            if (buttonAlign == "left")
            {
                titleTextField.setActualSize(
                    width - leftOffset - rightOffset -
                    Math.max((closeButton.x + closeButton.measuredWidth),
                    (minimizeButton.x + minimizeButton.measuredWidth),
                    (maximizeButton.x + maximizeButton.measuredWidth)) - 2,
                    measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING);

                titleTextField.move(
                    Math.max((closeButton.x + closeButton.measuredWidth),
                    (minimizeButton.x + minimizeButton.measuredWidth),
                    (maximizeButton.x + maximizeButton.measuredWidth)),
                    (height - (measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING))/2);

                titleTextField.truncateToFit();
            }
            else
            {
                titleTextField.setActualSize(
                    width - leftOffset - rightOffset -
                    (width - Math.min(closeButton.x,
                    minimizeButton.x, maximizeButton.x)) - 2,
                    measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING);

                titleTextField.move(
                    leftOffset,
                    (height - (measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING))/2);

                titleTextField.truncateToFit();
            }
        }
    }

        titleTextField.text = _title;
        titleTextField.validateNow();

        var buttonsX:Number; // x point between buttons and title text
        
        if( buttonAlign == "left" )
        {
            buttonsX = Math.max((closeButton.x + closeButton.measuredWidth),
                        (minimizeButton.x + minimizeButton.measuredWidth),
                        (maximizeButton.x + maximizeButton.measuredWidth));
        }
        else
        {
            buttonsX = Math.min(closeButton.x, minimizeButton.x, maximizeButton.x);
        }

        if (titleAlign == "left")
        {
            if (buttonAlign == "left")
            {
                titleTextField.setActualSize(
                    width - rightOffset - 2 - buttonsX,
                    measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING);

                titleTextField.move(
                    buttonsX,
                    (height - (measureChromeText(titleTextField).height +
                    UITextField.TEXT_HEIGHT_PADDING))/2);

