 {
 
 import flash.accessibility.Accessibility;
+import flash.display.Sprite;
 import flash.events.Event;
 import flash.events.MouseEvent;
 
 import mx.accessibility.AccConst;
 import mx.core.UIComponent;
 import mx.core.mx_internal;
+import mx.events.CloseEvent;
 
 import spark.components.Button;
 import spark.components.Panel;
 import spark.components.supportClasses.TextBase;
 import spark.components.TitleWindow;
 import spark.events.SkinPartEvent;
+import spark.events.TitleWindowBoundsEvent;
 
 use namespace mx_internal;
 

 *
 *  <p>When a Spark TitleWindow is created,
 *  the <code>accessibilityImplementation</code> property
 *  of its <code>titleDisplay</code> is set to an instance of this class.
 *  The Flash Player then uses this class to allow MSAA clients
 *  such as screen readers to see this component.
 *  See the mx.accessibility.AccImpl and

{
    include "../core/Version.as";

	//--------------------------------------------------------------------------
	//
	//  Class methods
	//
	//--------------------------------------------------------------------------

	/**
	 *  Enables accessibility in the TitleWindow class.
	 * 
	 *  <p>This method is called by application startup code
	 *  that is autogenerated by the MXML compiler.
	 *  Afterwards, when instances of TitleWindow are initialized,
	 *  the <code>accessibilityImplementation</code> property
	 *  of a special first child Sprite will be set to an instance
	 *  of this class.
	 *  If the TitleWindowAccImpl were attached to the TitleWindow itself
	 *  the accessibility implementations of the TitleWindow's children
	 *  would be ignored.</p>
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public static function enableAccessibility():void
	{
		TitleWindow.createAccessibilityImplementation =
			createAccessibilityImplementation;
	}

	/**
	 *  @private
	 *  Creates a TitleWindow's AccessibilityImplementation object.
	 *  This method is called from TitleWindow's
	 *  initializeAccessibility() method.
	 */
	mx_internal static function createAccessibilityImplementation(
								component:UIComponent):void
	{
		// The TitleWindowAccImpl is attached
		// not to the TitleWindow but to a special child Sprite.
		// If it were attached to the TitleWindow itself,
		// the AccessibilityImplementations of the TitleWindow's
		// children would be ignored.
		var accImpl:TitleWindowAccImpl = new TitleWindowAccImpl(component);
		var accImplSprite:Sprite = accImpl.attach();
		
		Accessibility.sendEvent(accImplSprite, 0, AccConst.EVENT_OBJECT_CREATE);
		Accessibility.updateProperties();
	}

	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------

	/**
	 *  Constructor.
	 *
	 *  @param master The UIComponent instance that this AccImpl instance
	 *  is making accessible.
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function TitleWindowAccImpl(master:UIComponent)
	{
		super(master);
		
        role = AccConst.ROLE_SYSTEM_PANE;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overridden properties: AccImpl
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  eventsToHandle
	//----------------------------------
	
	/**
	 *  @private
	 *  Array of events that we should listen for from the master component.
	 */
	override protected function get eventsToHandle():Array
	{
		return super.eventsToHandle.concat(
			[ TitleWindowBoundsEvent.WINDOW_MOVE_END, CloseEvent.CLOSE ]);
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overridden methods: AccessibilityImplementation
	//
	//--------------------------------------------------------------------------

	/**
	 *  @private
	 *  IAccessible method for returning the state of the TitleWindow.
	 *  States are predefined for all the components in MSAA.
	 *  Values are assigned to each state.
	 *  Depending upon the TitleWindow being Focusable, Focused and Moveable,
	 *  a value is returned.
	 *
	 *  @param childID:uint
	 *
	 *  @return State:uint
	 */
	override public function get_accState(childID:uint):uint
	{
		var accState:uint = getState(childID);
		
		accState |= AccConst.STATE_SYSTEM_MOVEABLE;
		
		return accState;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overridden event handlers: AccImpl
	//
	//--------------------------------------------------------------------------

	/**
	 *  @private
	 *  Override the generic event handler.
	 *  All AccImpl must implement this
	 *  to listen for events from its master component. 
	 */
	override protected function eventHandler(event:Event):void
	{
		super.eventHandler(event);

		switch (event.type)
		{
			case TitleWindowBoundsEvent.WINDOW_MOVE_END:
			{
				Accessibility.sendEvent(accImplSprite, 0,
					AccConst.EVENT_OBJECT_LOCATIONCHANGE, true);
				Accessibility.updateProperties();
				break;
			}
			
			case CloseEvent.CLOSE:
			{
				Accessibility.sendEvent(accImplSprite, 0,
										AccConst.EVENT_OBJECT_DESTROY, true);
				Accessibility.updateProperties();
				break;
			}
		}
	}
}

}
