When using shorthand notation:
x = {a:"first", b:"second", c:"third"};
properties are added in reverse order, so "c, b, a" as you can see when you hit
CTRL+ALT+V in test movie mode:
Variable _level0.x = [object #1, class 'Object'] {
c:"third",
b:"second",
a:"first"
}
That's why the 2 loops have different output.
So basically you're doing:
x = new Object();
x["c"] = "third";
x["b"] = "second";
x["a"] = "first";
y = new Object();
y["a"] = "first";
y["b"] = "second";
y["c"] = "third";
If you want them to look/behave the same, use the same notation for both.
x = {a:"first", b:"second", c:"third"};
y = {a:"first", b:"second", c:"third"};
regards,
Muzak
> On 9/11/07, Mendelsohn, Michael <[EMAIL PROTECTED]> wrote:
>> Hi list...
>>
>> I want object y, below, to output in the same order as x. Is it
>> possible?
>>
>> Thanks,
>> - Michael M.
>>
>> x = {a:"first", b:"second", c:"third"};
>> for (i in x) {
>> trace(i + ": " + x[i]);
>> }
>> /*
>> output:
>> a: first
>> b: second
>> c: third
>> */
>>
>>
>> y = new Object();
>> y["a"] = "first";
>> y["b"] = "second";
>> y["c"] = "third";
>> for (i in y) {
>> trace(i + ": " + y[i]);
>> }
>> /*
>> output:
>> c: third
>> b: second
>> a: first
>> */
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com