2 Replies Latest reply on Nov 14, 2008 11:51 AM by ice9_us

    AdvancedDataGrid is a null?

    2JZ Level 1
      I have an AdvancedDataGrid in module declared like following:

      <mx:AdvancedDataGrid id="MyGridCtrl" minHeight="175" height="100%"
      horizontalScrollPolicy="auto" minWidth="200" width="100%"/>

      public function PopulateGrid( MyXML:XML ):void
      MyGridCtrl.wordWrap = true;

      I tried to load the module from my application like below:
      private function PassData(x:XML):void
      var i:Number;
      var myXML:XML;
      var MyXMLList:XMLList;
      var MyGridCtrl:ModuleLoader;

      MyXMLList = x.advgrid;
      DataXMLList = MyXMLList;
      for( i=0; i<MyXMLList.length(); i++ )
      myXML = new XML( MyXMLList );
      MyGridCtrl = new ModuleLoader();
      MyGridCtrl.id = i.toString();
      MyGridCtrl.url = "modules/AdvDataGrid.swf";
      MyGridCtrl.percentWidth = int( TheHBox.percentWidth / MyXMLList.length() ) - 2;
      MyGridCtrl.percentHeight = TheHBox.percentHeight - 5;
      MyGridCtrl.addEventListener(ModuleEvent.READY, LoadModule );
      TheHBox.addChild( MyGridCtrl );
      private function LoadModule( event:ModuleEvent ):void
      var idx:Number = event.currentTarget.id;
      var MyXML:XML = DataXMLList[idx];
      var ichild:* = event.currentTarget.child as AdvDGModuleInterface;
      if ( event.currentTarget.child != null )
      ichild.PopulateGrid( MyXML );
      Alert.show("Uh oh. The mod.child property is null");

      Here is the problem. When the PopulateGrid() is called, MyGridCtrl is null. Why is that? I thought declaring in MXML style will set create the grid before anything else? The grid is the only item created in the module with a bunch of actionscript to modify its properties.

      Please help!