# Array Function Trouble

**URL:** https://forum.kirupa.com/t/array-function-trouble/213685
**Category:** flash
**Created:** [January 22, 2007, 2:53pm UTC](https://forum.kirupa.com/t/array-function-trouble/213685 "2007-01-22T14:53:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![decumbo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/decumbo/32/1890_2.png) [@decumbo](https://forum.kirupa.com/u/decumbo)
#### Post date: [January 22, 2007, 2:53pm UTC](https://forum.kirupa.com/t/array-function-trouble/213685/1 "2007-01-22T14:53:50Z")

</div>

Hi, I’m having some trouble getting my functions to give me my desired output…

```auto
// a quick example of a map
// tile1 = ([1, 2, 3, "walk", 0.45, 10]);
// tile2 = ([4, 5, 6, "wall", 0.23, 70]);
// mymap = ([([tile1,tile1,tile2]),
// ([tile2,tile2,tile2]) ]);
var newMap:Boolean = true;
var map:Array;
function createMap(w, h, tile) {
 var map:Array;
 for (var i = 0; i < h; ++i) {
  map.push(createRow(w, tile));
 }
 return map;
}
function createRow(w, tile) {
 var row:Array;
 for (var i = 0; i < w; ++i) {
  row.push(tile);
 }
 return row;
}
function mapHandle(w, h, map, default_tile) {
 var newmap:Array;
 var mapW = map[0].length;
 var mapH = map.length;
 if (newMap) {
  newmap = createMap(w, h, default_tile);
  return newmap;
 }
 else {
  if (w < mapW) {
   for (var i = 0; i < mapH; ++i) {
    for (var j = 0; j < (mapW - w); ++j) {
     map*.pop();
    }
   }
  }
  if (w > mapW) {
   for (var i = 0; i < mapH; ++i) {
    for (var j = 0; j < (w - mapW); ++j) {
     map*.push(default_tile);
    }
   }
  }
  if (h < mapH) {
   for (var i = 0; i < (mapH - h); ++i) {
    map.pop();
   }
  }
  if (h > mapH) {
   for (var i = 0; i < (h - mapH); ++i) {
     map.push(createRow(w, default_tile));
   }
  }
 }
}

```

… when I try to do something like this:

```auto
var testTile = ([1,2,3,4,5]);
var testMap = createMap(10,10,testTile);
trace(testMap);

```

I end up with undefined instead of my 10x10 3D array.

I’m working on [http://www.student.cs.uwaterloo.ca/~bbobnis/](http://www.student.cs.uwaterloo.ca/~bbobnis/) if that’s any aid at all.

I want to get an array instead of undefined. What am I doing wrong?

Thank you in advance,  
decumbo
