-
Does Flash support 2D Arrays?
-
curmudgeon
-
Is the syntax:
inv = new Array();
inv[item][ammount] = 3;
-
This is my understanding:
Arrays can have content of any data type--string, number, any object, other arrays, etc. If I understand correctly what you're trying to do, you could do something like this:
Code:
inv = new Array();
// inv[0] is the first item, with a subarray for the name
// of the item and the price
inv[0] = new Array();
inv[0][0] = itemName
inv[0][1] = itemPrice
Then repeat the last three lines for each item.
Now, I'm not sure the last two lines are the right way to access an array within an array. If that doesn't work, you could try a different method. That is, instead of having arrays nested in the "inv" array, you could have objects nested in the "inv" array. You would then assign each object two properties, "item" and "price". That would look something like this:
Code:
inv = new Array();
// inv[0] is the first item, with a subarray for the name
// of the item and the price
inv[0] = new Object();
inv[0] = {
item: value
price: value
any other property/value pairs you want
}
This object acts like a movie clip, where each property is a variable inside it. That means the properties can also be accessed and assigned with standard dot-notation, such as this:
Code:
inv[0].item = value
_root.itemPrintOut = inv[0].item
If that doesn't work, I'm stumped.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|