0

I'm writing a game in actionscript 3, I have a shared object that saves what inventory items you have collected. The data attributes of this shared object are for example:

inventorySO.data.appleInventory = false;
inventorySO.data.branchInventory = false;
inventorySO.data.tamagotchiInventory = false;

I've already worked out how to loop through the data attributes, is there any way that I can trace each data attribute so that my output is:

appleInventory

branchInventory

tamagotchiInventory

and not:

false

false

false

I couldn't see anything in the reference docs or online, so thanks very much to anyone who's able to help!

Romano

1 Answer 1

1

Use a for..in loop:

for(var prop:String in inventorySO.data)
{
    trace(prop);
}

Note that in this loop, you can access the value of each property iterated using:

inventorySO.data[prop];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.