<?xml version="1.0" encoding="utf-8"?>
<s:Application
    xmlns:fx        ="http://ns.adobe.com/mxml/2009" 
    xmlns:s            ="library://ns.adobe.com/flex/spark" 
    xmlns:mx        ="library://ns.adobe.com/flex/mx"
    xmlns:skins        ="creacog.spark.skins.*"
    xmlns:components="creacog.spark.components.*"
    minWidth        ="200"
    minHeight        ="200"
    width            ="400"
    height            ="300"
    preinitialize    ="handlePreinitialize( event )"
    creationComplete="handleCreationcomplete( event )"
    viewSourceURL    ="srcview/index.html" 
>
    <fx:Style>
        @namespace components "creacog.spark.components.*";
        
        components|ResizeableTitleWindow
        {
            skin-class : ClassReference( "creacog.spark.skins.ResizeableTitleWindowSkin" );
        }
        
    </fx:Style>
    
    <fx:Script>
        <![CDATA[
            import creacog.spark.components.ResizeableTitleWindow;
            import creacog.spark.events.TitleWindowBoundsEvent;
            import creacog.spark.skins.ResizeableTitleWindowMacSkin;
            import creacog.spark.skins.ResizeableTitleWindowSkin;
            
            import mx.events.FlexEvent;
            import mx.managers.PopUpManager;
            
            import spark.components.TitleWindow;
            import spark.events.TitleWindowBoundsEvent;

            protected function handlePreinitialize( event:FlexEvent ):void
            {
                if( Capabilities.os.indexOf( "Mac" ) == 0 )
                {
                    //OVERRIDE SOME STYLES/SKINS FOR MAC PLATFORM LAYOUTS
                    styleManager.loadStyleDeclarations( "mac.swf", true );
                }
            }

            protected function handleCreationcomplete( event:FlexEvent ):void
            {
                // A NORMAL SPARK TITLEWINDOW : A
                var titleWindowA :TitleWindow = new TitleWindow();
                
                titleWindowA.width    = 100;
                titleWindowA.height    = 100;
                titleWindowA.title    = "A";
                
                PopUpManager.addPopUp(    titleWindowA,
                                        this,
                                        false );
                
                // RESIZEABLE : B
                var rTitleWindowB :ResizeableTitleWindow = new ResizeableTitleWindow();
                
                rTitleWindowB.x            = 110;
                rTitleWindowB.width        = 100;
                rTitleWindowB.height    = 100;
                rTitleWindowB.title        = "B";                
                
                PopUpManager.addPopUp(    rTitleWindowB,
                                        this,
                                        false );
                
                // MONITOR EVENTS
                rTitleWindowB.addEventListener(
                    creacog.spark.events.TitleWindowBoundsEvent.WINDOW_RESIZE_START,
                    rTitleWindowB_titleWindowBoundsEventHandler );
                
                rTitleWindowB.addEventListener(
                    creacog.spark.events.TitleWindowBoundsEvent.WINDOW_RESIZING,
                    rTitleWindowB_titleWindowBoundsEventHandler );
                
                rTitleWindowB.addEventListener(
                    creacog.spark.events.TitleWindowBoundsEvent.WINDOW_RESIZE_END,
                    rTitleWindowB_titleWindowBoundsEventHandler );
                
                rTitleWindowB.addEventListener(
                    creacog.spark.events.TitleWindowBoundsEvent.WINDOW_RESIZE,
                    rTitleWindowB_titleWindowBoundsEventHandler );
                
                rTitleWindowB.addEventListener(
                    spark.events.TitleWindowBoundsEvent.WINDOW_MOVE,
                    rTitleWindowB_titleWindowBoundsEventHandler );
            }
            protected function rTitleWindowB_titleWindowBoundsEventHandler( e:Event ):void
            {
                trace( e.type );
            }

        ]]>
    </fx:Script>
    
</s:Application>