Help with for loops and variables

I need to have a Flash program I am creating loop through creation of 10 instances that each get populated by different dynamic XML files. Everything works fine, but if I can get some help with my for loops pasted below my code will go from 900 lines of code to about 200. There are three commented lines that explain what I need done. One at the beginning and two before the functions. Thanks

//needs to be a for loop, but the syntax that works aFacilityDataID* doesn’t seem to work when creating the variable.
var aFacilityDataID1:Array = new Array();
var aFacilityDataID2:Array = new Array();
var aFacilityDataID3:Array = new Array();
var aFacilityDataID4:Array = new Array();
var aFacilityDataID5:Array = new Array();
var aFacilityDataID6:Array = new Array();
var aFacilityDataID7:Array = new Array();
var aFacilityDataID8:Array = new Array();
var aFacilityDataID9:Array = new Array();
var aFacilityDataID10:Array = new Array();

//needs to loop through 10 instances of this function. Can you do that when making functions?
//also in this for loop, this works, aFacilityXpos7[j], but trying to do this doesn’t (aFacilityYpos[arrayNumber][j]). Is there a way to have the two side by side work together?
function sameSpace7(arrayNumber, nodesLength, currentX, currentY) {
for(j:Number = 0; j <= nodesLength -1; j++) {;
if (((currentX-aFacilityXpos7[j])<=11) && ((currentX-aFacilityXpos7[j])>=-11)) {
if (((currentY-aFacilityYpos7[j])<=11) && ((currentY-aFacilityYpos7[j])>=-11)) {
if (arrayNumber != j) {
_root.container_mc.firstload[“instance”+arrayNumber]._y = (_root.container_mc.firstload[“instance”+j]._y+15);
}
}
}
}
}
function sameSpace8(arrayNumber, nodesLength, currentX, currentY) {
for(j:Number = 0; j <= nodesLength -1; j++) {;
if (((currentX-aFacilityXpos8[j])<=11) && ((currentX-aFacilityXpos8[j])>=-11)) {
if (((currentY-aFacilityYpos8[j])<=11) && ((currentY-aFacilityYpos8[j])>=-11)) {
if (arrayNumber != j) {
//trace(arrayNumber + " arrayNumber");
//trace(j+ " j");
_root.container_mc.firstload[“instance”+arrayNumber]._y = (_root.container_mc.firstload[“instance”+j]._y+15);
}
}
}
}
}
function sameSpace9(arrayNumber, nodesLength, currentX, currentY) {
for(j:Number = 0; j <= nodesLength -1; j++) {;
if (((currentX-aFacilityXpos9[j])<=11) && ((currentX-aFacilityXpos9[j])>=-11)) {
if (((currentY-aFacilityYpos9[j])<=11) && ((currentY-aFacilityYpos9[j])>=-11)) {
if (arrayNumber != j) {
_root.container_mc.firstload[“instance”+arrayNumber]._y = (_root.container_mc.firstload[“instance”+j]._y+15);
}
}
}
}
}