Skip to main content
Inspiring
May 22, 2013
Question

Hard to word this problem as a short title, but i have array referring problems

  • May 22, 2013
  • 1 reply
  • 1139 views

Ok, so I got this:

var bm:Bitmap = new Bitmap(backgroundBlocks[row0 - 1]);

backgroundBlocks is an array, so is row0. I'm trying to make row0 into a this["row"+rowNumber], with a so I can navigate within it.

I fail in everything I've tried. Only way I can make this work is if I make 10 rows of "var bm:Bitmap = new Bitmap(backgroundBlocks[row0 - 1]);" with "row0", "row1", "row2" etc, but that's just lame, so there must be a way where I can change the number outside so whenever I call that line it uses the row number specified.

Any ideas?

This topic has been closed for replies.

1 reply

Inspiring
May 22, 2013

Not sure what you are trying to achieve here.

Is row0 an array filled with Bimapdata-objects?

How to proper instantiate a Bitmap Object.

TenchyMyoAuthor
Inspiring
May 22, 2013

Nah, row0 is just an array filled with numbers.

This works: var bm:Bitmap = new Bitmap(backgroundBlocks[row0 - 1])

and I just need to know how to change the "row0" part dynamically. I know how to do it if it's by itself, like this["row"+rowNumber], but that doesn't seem to work in that line of code.

backgroundBlocks however contains bitmaps, but it's irrelevant I'm sure.

I'm almost done with a workaround, not as good but should work. I instead make a new var called tempArrayForRows and just "tempArrayForRows = ["row" + rowNumber];" before doing "var bm:Bitmap = new Bitmap(backgroundBlocks[row0 - 1])" and it should work....   just not as convenient.

Still hope someone knows a better way to do what I've explain in my first post.

removed "this" from "tempArrayForRows = this["row" + rowNumber];"

TenchyMyoAuthor
Inspiring
May 22, 2013

Hmm, can't do tempArrayForRows = this["row"+0] or even tempArrayForRows = this["row"+0]. The first one gives TypeError: Error #1009: Cannot access a property or method of a null object reference. The second one just throws all out all bitmaps as undefined. But simply tempArrayForRows = row0 (row1, row2 etc...) works though. First time I encounter this problem as I've never done something exactly like this before, but I've done a lot of similar things.

Any ideas? I wanna copy everything in the row0 (etc...) array(s) to tempArrayForRows, but doesn't work if I this["row"+whatever], which has worked for pretty much everything in the past.

Another idea I might try is to put all the row arrays in a new array and cycle through them like that instead, then no need for this["row"+bleh]... if now THAT work...