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

<mx:Script>
    <![CDATA[
    
        import com.augiemarcello.urlRequestFile.dataProviders.URLRequestObj;
        
        [Bindable]
        public var filePath:String = "xml/names.xml"
        public var urlRequestObject:URLRequestObj;
        
        /*
        * Pass in componets to the URLRequestObject class. This is only ONE OF MANY means of providing scope back to components.
        * Another way would be to utilize Data Binding or an Event driven model
        */
        private function sendFile():void
        {    
            this.urlRequestObject = new URLRequestObj(this.filePathInput.text, this.loaderProgress, this.xmlLoadedDisplay, this.dg);
        }
        
        private function reset():void
        {
            this.filePathInput.text = this.filePath;
            this.loaderProgress.htmlText = null;
            this.xmlLoadedDisplay.text = null;
            this.dg.dataProvider = null;
        }
        
    ]]>
</mx:Script>

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


    <mx:Panel width="750" height="600" >
                <mx:Text  width="100%" height="29" text="URL Request File / XML Parser" styleName="header"/>
                <mx:Text text="FLEX 2.0 / ActionScript3 - Beginner" styleName="subHeader" />
        <mx:HBox  width="100%" height="100%">
            <mx:VBox width="30%" height="100%">
                    <mx:TextInput id="filePathInput" text="{this.filePath}" width="100%"/>
                <mx:HBox width="100%">
                    <mx:Button click="this.sendFile();" label="Send"  />
                    <mx:Button click="reset(); " label="Reset"  />
                </mx:HBox>
                <mx:Text text="Loader Progress::" />
                <mx:TextArea id="loaderProgress"  width="100%"  borderStyle="none"/>
                <mx:Text text="Loaded XML::" />
                <mx:TextArea id="xmlLoadedDisplay" height="100%"  width="100%"/>
            </mx:VBox>
            
            <mx:DataGrid id="dg"  width="70%" height="100%">
                <mx:columns>
                    <mx:DataGridColumn headerText="Id" dataField="@id" width="25"/>
                    <mx:DataGridColumn headerText="First Name" dataField="@firstName"/>
                    <mx:DataGridColumn headerText="Last Name" dataField="@lastName"/>
                    <mx:DataGridColumn headerText="Blog Url" dataField="@blog"/>
                    <mx:DataGridColumn headerText="Email" dataField="@email"/>
                </mx:columns>
            </mx:DataGrid>
            
        </mx:HBox>
                <mx:Label styleName="footer">
               <mx:htmlText><![CDATA[<a href="www.augiemarcello.com"><b>www.augiemarcello.com</b></a>]]></mx:htmlText>
           </mx:Label>
        
    </mx:Panel>
    
</mx:Application>