Array to DataGrid not working. Please help before I lose my mind (and my hair) completely.

Hi,
I'm new to the whole flex/as/flash builder, but I'm trying to do a seemingly simple thing and it's not working.
Flex Mobile project has a button and data grid. When I press the button a 2 dimensional array is build with random numbers. Then I want to show the array on datagrid.
The array does get build but it's not showing up on data grid.
Any help would be appreciated as I've spent lots of time on this without any solution.
Thanks,
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
  <![CDATA[
   import flash.events.Event;
   import mx.collections.ArrayList;  
   import mx.collections.ArrayCollection;
   import spark.events.ViewNavigatorEvent;
   protected function cmdStart1_clickHandler(event:MouseEvent):void
    DataGridTest1();
   protected function DataGridTest1():void
    var board:Array = [];
    var arrList:ArrayList = new ArrayList();
    var i:int = 1;
    var j:int;
    text.text = "";
    for(i; i<=5; i++)
     board[i] = [];
     j = 1;
     for(j; j<=6; j++)
      board[i][j] = Math.round(Math.random() * 10);
    arrList.source = board;
    grid.dataProvider = arrList; 
  ]]>
</fx:Script>
<s:Button id="cmdStart1" x="53" y="100" width="394" height="62" label="DataGridTest1 (ArrayList to Grid)"
     click="cmdStart1_clickHandler(event)"/>
<s:TextArea id="text" x="53" y="240" width="394" height="162"/>
</s:View>

Sorry, the <s:TextArea shouldn't be there, I was using it to debug the array. I removed the  <s:DataGrid> instead of <s:TextArea> by mistake.
Also, I tried to move arrList out of the function but that didn't work.
Here's the entire code again:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
  <![CDATA[
   import flash.events.Event;
   import mx.collections.ArrayList;  
   import mx.collections.ArrayCollection;
   import spark.events.ViewNavigatorEvent;
   protected function cmdStart1_clickHandler(event:MouseEvent):void
    DataGridTest1();
   protected function DataGridTest1():void
    var board:Array = [];
    var arrList:ArrayList = new ArrayList();
    var i:int = 1;
    var j:int;
    text.text = "";
    for(i; i<=5; i++)
     board[i] = [];
     j = 1;
     for(j; j<=6; j++)
      board[i][j] = Math.round(Math.random() * 10);
    arrList.source = board;
    grid.dataProvider = arrList; 
  ]]>
</fx:Script>
<s:Button id="cmdStart1" x="53" y="100" width="394" height="62" label="DataGridTest1 (ArrayList to Grid)"
     click="cmdStart1_clickHandler(event)"/>
<s:DataGrid id="grid" x="500" y="100" width="236" height="226" />
</s:View>

Similar Messages

Maybe you are looking for