Draw() problem?

Im trying to create some class that will take two arrays of DisplayObjects, mask each item of one with the item on another with same index, create an array full of BitmapDatas and make each of those BitmapDatas draw the masked DisplayObject with same index, and return the array of BitmapDatas
However i dont know why its not working

ActionScript Code:
[FONT=Courier New][LEFT]</p>
<p>[COLOR=#808080]/</p>
<p>this class returns an array of BitmapDatas made of two other Arrays</p>
<p>it masks one with the second and draws all to create the BitmapData</p>
<p> </p>
<p>/[/COLOR]</p>
<p>package[COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]geom[/COLOR].[COLOR=#000080]Point[/COLOR];</p>
<p> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]geom[/COLOR].[COLOR=#000080]Rectangle[/COLOR];</p>
<p> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]display[/COLOR].[COLOR=#000080]DisplayObject[/COLOR];</p>
<p> [COLOR=#0000ff]import[/COLOR] flash.[COLOR=#000080]display[/COLOR].[COLOR=#000080]BitmapData[/COLOR];</p>
<p> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000]class[/COLOR] BmdtFromArrayMasks[COLOR=#000000]{[/COLOR]</p>
<p> </p>
<p> [COLOR=#000000]var[/COLOR] arrayMask:[COLOR=#0000ff]Array[/COLOR];</p>
<p> [COLOR=#000000]var[/COLOR] arrayToBeMasked:[COLOR=#0000ff]Array[/COLOR];</p>
<p> [COLOR=#000000]var[/COLOR] rec:Rectangle;</p>
<p> [COLOR=#000000]var[/COLOR] zepo:Point;</p>
<p> [COLOR=#000000]var[/COLOR] len:[COLOR=#0000ff]int[/COLOR];</p>
<p> [COLOR=#000000]var[/COLOR] wi:[COLOR=#0000ff]Number[/COLOR];</p>
<p> [COLOR=#000000]var[/COLOR] he:[COLOR=#0000ff]Number[/COLOR];</p>
<p> [COLOR=#000000]var[/COLOR] initialColor:uint;</p>
<p> </p>
<p> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000]function[/COLOR] BmdtFromArrayMasks[COLOR=#000000]([/COLOR]arm:[COLOR=#0000ff]Array[/COLOR], artb:[COLOR=#0000ff]Array[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> arrayMask = arm;</p>
<p> arrayToBeMasked = artb;</p>
<p> [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR]arrayMask[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] is DisplayObject [COLOR=#000000])[/COLOR] == [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]" first array must have DisplayObjects inside"[/COLOR][COLOR=#000000])[/COLOR];</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR]arrayToBeMasked[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] is DisplayObject [COLOR=#000000])[/COLOR] == [COLOR=#000000]false[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]" second array must have DisplayObjects inside"[/COLOR][COLOR=#000000])[/COLOR];</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> rec = [COLOR=#000000]new[/COLOR] Rectangle[COLOR=#000000]([/COLOR][COLOR=#000080]0[/COLOR],[COLOR=#000080]0[/COLOR], arrayMask[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]width[/COLOR] , arrayMask[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]height[/COLOR][COLOR=#000000])[/COLOR];</p>
<p> zepo = [COLOR=#000000]new[/COLOR] PointCOLOR=#000000[/COLOR];</p>
<p> len = arrayMask.[COLOR=#0000ff]length[/COLOR];</p>
<p> wi = arrayMask[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]width[/COLOR];</p>
<p> he = arrayToBeMasked[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]height[/COLOR];</p>
<p> </p>
<p> initialColor = 0xFF000000;</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> [COLOR=#0000ff]public[/COLOR] [COLOR=#000000]function[/COLOR] generateCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Array[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> [COLOR=#000000]var[/COLOR] bitmapDataArray:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR]; </p>
<p> </p>
<p> [COLOR=#808080]//loop in all</p>[/COLOR]
<p> [COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] i:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]0[/COLOR] ; i<len ; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> </p>
<p> [COLOR=#808080]//put in same place, mask</p>[/COLOR]
<p> arrayMask[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]x[/COLOR] = arrayToBeMasked[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]x[/COLOR] = arrayMask[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]y[/COLOR] = arrayToBeMasked[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]y[/COLOR] = [COLOR=#000080]1[/COLOR];</p>
<p> arrayMask[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]cacheAsBitmap[/COLOR] = [COLOR=#000000]true[/COLOR];</p>
<p> arrayToBeMasked[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]cacheAsBitmap[/COLOR] = [COLOR=#000000]true[/COLOR];</p>
<p> arrayToBeMasked[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]mask[/COLOR] = arrayMask[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR];</p>
<p> </p>
<p> [COLOR=#808080]//create the BitmapData and draw it</p>[/COLOR]
<p> bitmapDataArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#000000]new[/COLOR] BitmapDataCOLOR=#000000[/COLOR];</p>
<p> bitmapDataArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]draw[/COLOR]COLOR=#000000[/COLOR];</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> [COLOR=#0000ff]return[/COLOR]COLOR=#000000[/COLOR];</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> </p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p> </p>
<p>
[/LEFT]
[/FONT]

And this is in the fla:

ActionScript Code:
[FONT=Courier New][LEFT]</p>
<p>var len:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]5[/COLOR];</p>
<p>var ar1:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p>var bmdt:BitmapData = [COLOR=#000000]new[/COLOR] BitmapData[COLOR=#000000]([/COLOR][COLOR=#000080]20[/COLOR],[COLOR=#000080]20[/COLOR],[COLOR=#000000]true[/COLOR], 0xFFFF0000[COLOR=#000000])[/COLOR];</p>
<p>for[COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] i:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]0[/COLOR] ; i<len ; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> ar1[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#000000]new[/COLOR] BitmapCOLOR=#000000[/COLOR];</p>
<p> addChildCOLOR=#000000[/COLOR];</p>
<p> </p>
<p> </p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p>var bmdt2:BitmapData = [COLOR=#000000]new[/COLOR] BitmapData[COLOR=#000000]([/COLOR][COLOR=#000080]20[/COLOR],[COLOR=#000080]20[/COLOR],[COLOR=#000000]true[/COLOR], 0xAA00FF00[COLOR=#000000])[/COLOR];</p>
<p>var ar2:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p>for[COLOR=#000000]([/COLOR]i = [COLOR=#000080]0[/COLOR] ; i<len ; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> ar2[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#000000]new[/COLOR] BitmapCOLOR=#000000[/COLOR];</p>
<p> addChildCOLOR=#000000[/COLOR];</p>
<p> </p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p>var bmTest:BmdtFromArrayMasks = [COLOR=#000000]new[/COLOR] BmdtFromArrayMasks[COLOR=#000000]([/COLOR]ar1, ar2[COLOR=#000000])[/COLOR];</p>
<p>var ret:[COLOR=#0000ff]Array[/COLOR] ;</p>
<p>ret = bmTest.[COLOR=#000080]generate[/COLOR]COLOR=#000000[/COLOR];</p>
<p>var returnBitmap:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];</p>
<p>for[COLOR=#000000]([/COLOR][COLOR=#000000]var[/COLOR] j:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]0[/COLOR] ; j< len ; j++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> returnBitmap[COLOR=#000000][[/COLOR]j[COLOR=#000000]][/COLOR] = [COLOR=#000000]new[/COLOR] BitmapCOLOR=#000000[/COLOR];</p>
<p> </p>
<p> addChildCOLOR=#000000[/COLOR];</p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p> </p>
<p>var placeX:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]100[/COLOR];</p>
<p>var placeY:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]100[/COLOR];</p>
<p>this.[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“enterFrame”[/COLOR], oef[COLOR=#000000])[/COLOR];</p>
<p>var frame:[COLOR=#0000ff]int[/COLOR] = [COLOR=#000080]0[/COLOR];</p>
<p>function oefCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> frame++;</p>
<p> </p>
<p> [COLOR=#0000ff]if[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]</p>
<p> frame = [COLOR=#000080]0[/COLOR];</p>
<p> [COLOR=#000000]}[/COLOR]</p>
<p> </p>
<p> returnBitmap[COLOR=#000000][[/COLOR]frame[COLOR=#000000]][/COLOR].[COLOR=#000080]x[/COLOR] = mouseX;</p>
<p> returnBitmap[COLOR=#000000][[/COLOR]frame[COLOR=#000000]][/COLOR].[COLOR=#000080]y[/COLOR] = mouseY;</p>
<p> </p>
<p>[COLOR=#000000]}[/COLOR]</p>
<p> </p>
<p> </p>
<p>
[/LEFT]
[/FONT]

Any idea why its not working?Thanks in advance