Flex simple question

Here is my main file:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="[L=http://www.adobe.com/2006/mxml"]http://www.adobe.com/2006/mxml"[/L] layout="absolute" xmlns:comp="components.*" initialize="xmlData.send()">

    <mx:Script>
        <=!=[=C=D=A=T=A=[
            
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            
            [Bindable]
            public var dataGridData:ArrayCollection;
            
            private function httpResultHandler(event:ResultEvent):void {
                dataGridData = event.result.account.data;
            }
            
        ]=]=>
    </mx:Script>
    <mx:HTTPService url="index2.php" id="xmlData" result="httpResultHandler(event)" showBusyCursor="true"/>

    <comp:totalPanel dataGridData="{dataGridData}" x="1060" y="412"/>
</mx:Application>

Here is my component totalPanel file:


<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="[L=http://www.adobe.com/2006/mxml"]http://www.adobe.com/2006/mxml"[/L] layout="absolute">
    
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            
            public var dataGridData:ArrayCollection;
            private var dataLength:Number  = dataGridData.length;
    
        ]]>
    </mx:Script>

</mx:Panel>

My main (dataGridData="{dataGridData}") will pass in the dataGridData into the component. But my component (private var dataLength:Number = dataGridData.length) was unable to get the length of dataGridData, and giving “Cannot access a property or method of a null object reference” error message. I debug and realized at the time flex initiate this variable, the data “dataGridData” haven’t past in yet. It was past in later.
So how do I change my code to let it able to get the length after the dataGridData have past in?

Thanks.