Wow, a lot of misinformation here gents.

this._data["a"] = {"1":new Number(0), "2":new Number(0), "3":new
Number(0)};

When creating a new object using this syntax the property names are 
considered strings. Adding the quotes is what is causing the issue. If you 
remove the quotes the compiler will still complain because you can start a 
property value with a number, unless you use the [] syntax for creating a 
property. In that case you can use anything you want, even non-printable 
characters.

"
> As you have discovered you are not able to use numbers as
> keys in line objects.

That's not true.

Just wrote this and it works fine.

a = {};
a["a"] = {};
a["a"][1] = new Number(5);
trace(a["a"][1]);
"

The quote was "in line objects", so the statement was true. What you did 
was take the "in line objects" and represent it in a different manner.

"The second line does not work because you are evaluating a string to try 
to resolve it to a property of the object, (which you are hoping is a 
sub-object) that does not exist yet."

No, he wasn't.

this._data = new Object(); // Fine
this._data["a"] = {}; // Still fine

this._data was created, then this._data.a is created afterwards using the 
{} syntax instead of new Object().

That's why this still produces errors:
"
private function createData():Void {
this._data = new Object();
this._data["a"] = new Object();
this._data["a"] = {"t1":0, "t2":0};
}
"

If you MUST have numbers as the property values, use Chris Benjaminsen's 
version:

function createObj():Void {
this._data = new Object();
this._data["a"] = new Object();
this._data["a"][1] = new Number(0)
...
}


Derek Vadneau

----- Original Message ----- 
From: "Mendelsohn, Michael" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Friday, February 09, 2007 1:08 PM
Subject: SPAM-LOW: [Flashcoders] Identifier expected


Hi list...

Simple question -- why doesn't the 2nd line work?  The identifier
expected error is traced at compile time.

Thanks,
- Michael M.


function createObj():Void {
this._data = new Object();
this._data["a"] = {"1":new Number(0), "2":new Number(0), "3":new
Number(0)};
}


_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

Reply via email to