Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to order dictionary object

Community Beginner ,
Jan 17, 2014 Jan 17, 2014

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

@flash

TOPICS
ActionScript
737
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2014 Jan 17, 2014

Test no problem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2014 Jan 17, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 18, 2014 Jan 18, 2014

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)

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 18, 2014 Jan 18, 2014
LATEST

Thanks for your reply...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines