<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()" backgroundColor="#ffffff" viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            
            [Bindable]
            private var ac:ArrayCollection = new ArrayCollection();
            
            [Bindable]
            private var myText:String = "This example shows that when you change your timezone on your local computer it changes the data that comes back from coldfusion... say, you cahnge to pacific time, you now will see 2/19 as the first row in the grid... this is BAD.  how do you stop this... anyone? and don't tell me to loop over the data, i'm dealing with THOUSANDS OF RECORDS! that would bog the project down too much.";
            
            [Bindable]
            private var cfcText:String = '';


            private function init():void
            {
                cfcText += "QueryAddRow(q,3);\n";
                cfcText += "QuerySetCell(q,'myDate','2/20/08',1); \n";
                cfcText += "QuerySetCell(q,'myText','First Date',1);\n\n";
    
                cfcText += "QuerySetCell(q,'myDate','2/19/08',2);\n";
                cfcText += "QuerySetCell(q,'myText','Second Date',2);\n\n";
    
                cfcText += "QuerySetCell(q,'myDate','2/18/08',3);\n";
                cfcText += "QuerySetCell(q,'myText','Second Date',3);\n\n";
                
                cfcText += "return q";
                
                myRemoteObj.GetMyDates();
                
            }
            
            private function onResult(event:ResultEvent):void{
                ac = event.result as ArrayCollection;
            }
        ]]>
    </mx:Script>
    
    <mx:Style source="style.css"/>
    
    <mx:RemoteObject id="myRemoteObj" 
        destination="ColdFusion" 
        source="Examples.cfc.DateTimeWierdness"
        result="onResult(event)" 
        fault="Alert.show(event.fault.faultString)" 
        endpoint="http://axel.cfwebtools.com/flex2gateway/"/>
    
    <mx:VBox width="100%" height="100%">
        <mx:Text height="150" width="400" text="{myText}"/>
        <mx:Text height="100" width="400" text="NOTE: you have to open a new browser with this page, everytime you change your timezone to see the effects, or do a hard refresh in firefox, by holding CTRL and clicking refresh (F5)"/>
        <mx:HBox width="100%" height="100%">
            <mx:VBox width="50%" height="100%">
                <mx:Label text="CFC CODE: " fontWeight="bold" fontSize="20"/>
                <mx:Text height="100%" width="100%" text="{cfcText}" />
            </mx:VBox>
            <mx:DataGrid dataProvider="{ac}" width="100%" height="100%"/>
        </mx:HBox>
    </mx:VBox>
</mx:Application>