all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

Get the key of an array?


Re: Get the key of an array? eRez
7/25/2006 3:08:11 PM
flash actionscript:
u simply forgot 3 meaningfull chars:
var myObject:Array = [];

now try tracing.
eRez

[quoted text, click to view]

Get the key of an array? howachen
7/25/2006 7:46:58 PM
var myObject:Array ;

myObject['name'] = "1";
myObject['age'] = "2";
myObject['sex'] = "3";

for (var s in myObject) {
trace ("myObject." + s + " = " + myObject[s]);
}

this doesn't work...

i want to print out "name=1", "age=2"

Re: Get the key of an array? howa
7/25/2006 9:38:02 PM
well, what is the meaning of " = []; "

in fact, without these characters, the array still work

....

thanks as i am new to as...


[quoted text, click to view]
Re: Get the key of an array? Jeckyl
7/25/2006 10:58:33 PM
Then just make a change to how you trace it...

var myObject:Array = [];
myObject['name'] = "1";
myObject['age'] = "2";
myObject['sex'] = "3";
for (var s in myObject) {
trace ("s + " = " + myObject[s]);
}
--
Jeckyl

Re: Get the key of an array? Jeckyl
7/26/2006 12:00:00 AM
[quoted text, click to view]

No difference

var myObject:Array = new Array();

and

var myObject:Array = [];

are identical

how about you actually try it , and you'd SEE that it works the same.
--
Jeckyl

Re: Get the key of an array? Jeckyl
7/26/2006 12:00:00 AM
[quoted text, click to view]

it is actually setting the variable ot have a n array in it .. wirthout
setting it = to something, the variable remains undefined and you cannot do
'myObject["name"] = "1"' etc.

[quoted text, click to view]

no .. it won't
--
Jeckyl

Re: Get the key of an array? howa
7/26/2006 12:00:32 AM
if i use the following syntax, how to do it?


var myObject:Array = new Array();

what is the difference?



[quoted text, click to view]
AddThis Social Bookmark Button