Copy link to clipboard
Copied
hi,
i have created a dictionary object like below. when i trace, it is displaying in different order..
myDict["1"] = {name:"one"};
myDict["2"] = {name:"two"};
myDict["3"] = {name:"three"};
myDict["4"] = {name:"four"};
myDict["5"] = {name:"five"};
for (var key:Object in myDict)
{
trace("key ------- ",myDict[key].name)
}
output
key ------- two
key ------- four
key ------- five
key ------- three
key ------- one
any suggestion on how to get correct order.
Thanks in advance
Copy link to clipboard
Copied
Test no problem
Copy link to clipboard
Copied
sorry it works for me too, i change my dictionary object as like below.. now it showing in different order like below
myDict["one"] = {name:"one - 1"};
myDict["two"] = {name:"two - 2"};
myDict["three"] = {name:"three - 3"};
myDict["four"] = {name:"four - 4"};
myDict["five"] = {name:"five - 5"};
key2 ------- five - 5
key2 ------- four - 4
key2 ------- three - 3
key2 ------- two - 2
key2 ------- one - 1
Copy link to clipboard
Copied
Consider using an array or so others reply, checked API for in the object properties are not saved in any particular order;
var arr:Array=[{name:"one"},{name:"two"},{name:"three"},{name:"four"},{name:"five"}];
for each(var key:Object in arr)
{
trace("key ------- ",key.name)
}
Copy link to clipboard
Copied
Thanks for your reply...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now