0

i am trying to return the Value of the Objects name, any help would be a huge help! thank you.

var o:Object = new Object();
var n:String = "NAME"
o[n] = "DATA";

for each (var p in o){
trace("name="+o[p]+" data="+p);
}

outputs - name=undefined data=DATA

where it should be outputting - name=NAME data=DATA

2 Answers 2

1

For looping thru Object properties, drop the "each":

var o:Object = new Object();
var n:String = "NAME"
o[n] = "DATA";

for (var p in o)
{
    trace("name="+o[p]+" data="+p);
}
Sign up to request clarification or add additional context in comments.

Comments

0

I believe you want to use a regular for loop vs a "for each" loop http://active.tutsplus.com/tutorials/actionscript/as3-101-loops/

1 Comment

how do you loop through and Object with a regular loop?

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.