<?xml version="1.0" encoding="utf-8"?>
<mx:Application pageTitle="Style Creator" xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" viewSourceURL="srcview/index.html">

<!--
Copyright 2005-2006 Adobe Systems Inc., Adobe Consulting, and Peter Baird with
thanks to Ryan Hicks.  

This work is licensed under a Creative Commons License.  You may freely 
duplicate, distribute, display and alter this application for both 
commercial and non-commercial uses, but you must include this attribution, 
as well as the links to Adobe Systems and Adobe Consulting if the footer 
of the application.

For more information contact pbaird@adobe.com.
-->
    <mx:Script>
        <![CDATA[
        import mx.core.Container
        import flash.net.FileReference;
        import flash.net.URLRequest;
        import flash.net.URLRequestMethod;
        import flash.net.URLVariables;


        public function concatCSS():String
        {    
            var newCSS:String = "";
            for each (var vsc:DisplayObject in myViewstack.getChildren())
            {
                var cb:Box = Box(vsc);
                if (cb.numChildren > 0)
                    newCSS += Object(cb.getChildAt(0)).myCSS.text + "\n\n";
            }
            
           return newCSS;
        } 
        

        private function saveToFile():void
        {
            
            var appUrl:URLRequest = new URLRequest();
            appUrl.url = "application/data_to_file";
            appUrl.method = URLRequestMethod.POST;
            
            var variables:URLVariables = new URLVariables();
            variables.content = concatCSS();
            variables.suggested_name = "stylesCreator.css";
                
            appUrl.data = variables;
    
            navigateToURL(appUrl, "_top");

        }
       
        ]]>
       </mx:Script>


<mx:Style source="css/fse.css" />

<mx:Box width="100%" height="100%" id="myBackgroundImage" styleName="noPadding" backgroundAlpha="0" backgroundSize="100%" >
<mx:Box width="100%" height="100%" id="myBackground" paddingLeft="20" paddingRight="20" paddingTop="10" paddingBottom="5" backgroundAlpha="0" >
<mx:VBox horizontalAlign="left" width="100%" verticalGap="5">
    <mx:HBox horizontalGap="0" styleName="noPadding" verticalAlign="bottom">
        <mx:Label text="Flex 2: Style Creator" styleName="styleExplorerTitle" />
    </mx:HBox>
    <mx:ApplicationControlBar width="100%"  styleName="fseAppControlBar">
        <mx:LinkBar dataProvider="myViewstack" styleName="componentLinkBar" />
        <mx:Spacer width="100%"/>
        <mx:Button label="Download CSS" click="uploadFile()"/>
    </mx:ApplicationControlBar>    
</mx:VBox>
<mx:ViewStack width="100%" height="100%" id="myViewstack" >

    <mx:Box width="100%" height="100%" label="Application" >
        <fse:ExplorerApplication xmlns:fse="*" /> 
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="Panels"  >
        <fse:ExplorerPanels xmlns:fse="*" />
    </mx:Box>

    <mx:Box width="100%" height="100%" label="Tabs" id="tabs" >
        <fse:ExplorerTabs xmlns:fse="*" />
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="Accordions" id="accordions" >
        <fse:ExplorerAccordions xmlns:fse="*" />
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="Bars" id="linkbar">
        <fse:ExplorerLinkBar xmlns:fse="*" />
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="Lists &amp; Data Grids" id="lists" >
        <fse:ExplorerLists xmlns:fse="*" />
    </mx:Box> 
    
    <mx:Box width="100%" height="100%" label="Form Elements" id="form" >
        <fse:ExplorerFormElements xmlns:fse="*" />
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="Buttons" id="buttons"  >
        <fse:ExplorerButtons xmlns:fse="*" />
    </mx:Box>
    
    <mx:Box width="100%" height="100%" label="ScrollBars" id="scrollbars" >
            <fse:ExplorerScrollbars xmlns:fse="*" />
    </mx:Box>

    <mx:Box width="100%" height="100%" label="DateChooser" id="dateChooser">
            <fse:ExplorerDateChooser xmlns:fse="*" />
    </mx:Box>
    
      <mx:Box width="100%" height="100%" label="Other" id="other">
            <fse:ExplorerOther xmlns:fse="*" />
    </mx:Box>
        
    <mx:Box width="100%" height="100%" label="Text Formating" id="text" >
        <fse:ExplorerText xmlns:fse="*" />
    </mx:Box>
    
</mx:ViewStack>

<mx:HBox width="100%">
    <mx:Box horizontalAlign="left" width="50%">
        <mx:LinkButton label="Copyright (c) 2006 Adobe Systems, Inc. All Rights Reserved" 
            click="navigateToURL(new URLRequest('http://www.adobe.com/'));"
            styleName="footerLink"
            />
    </mx:Box>
    <mx:Box horizontalAlign="right" width="50%">
    <mx:LinkButton label="Created by Adobe Consulting" 
            click="navigateToURL(new URLRequest('http://weblogs.macromedia.com/mc/'));"
            styleName="footerLink"
            textDecoration="underline"
            />
    </mx:Box>
</mx:HBox>
</mx:Box>
</mx:Box> 
</mx:Application>