Looping and variables

I need to make a loop that can create (and use) incremented variable names.

Basically I need to dynamically create a certain number of sprites and datagrids then I need to add these dynamically created datagrids and sprites to the stage.

So the static code (which works, but I think is NOT the right way to go) would look something like this (I’m leaving out a bunch of stuff but this should give you the right idea):

var DataGrid0:DataGrid = new DataGrid();
var DataGrid1:DataGrid = new DataGrid();
var DataGrid2:DataGrid = new DataGrid();
var DataGrid3:DataGrid = new DataGrid();

addChild(DataGrid0);
addChild(DataGrid1);
addChild(DataGrid2);
addChild(DataGrid3);

DataGrid0.dataProvider = dp;
DataGrid1.dataProvider = dp;
DataGrid2.dataProvider = dp;
DataGrid3.dataProvider = dp;

I thought that I could do something like this:


for ( var i:int = 0; i<= numberOfLoops; i++) {        
     var DataGrid*:DataGrid = new DataGrid();
     addChild(DataGrid*);
     DataGrid*.dataProvider = dp;
}

But I can’t figure out the syntax and how to make it work…
Anybody have any ideas?! This MUST be possible!
My knowledge is pretty thin in actionscript, so please be gentle to me! Thank you in advance!
-Logan