RE: [Flashcoders] Identifier expected
Funny, Danny. I'm hoping someday it will all be just one language. - MM You can tell that Michael is mostly a Director user, can't you? :) ___ 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
RE: [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)}; } You can tell that Michael is mostly a Director user, can't you? :) In Lingo, we have property lists, which can use strings or numbers as properties. So ["1":0, "2":0, "3":0] would be a valid Lingo propList, but ActionScript isn't quite the same, as others have explained. My guess is that you're trying to match an AS list to a Lingo list without worrying about the fact that Lingo lists are 1-based rather than 0-based. A simpler solution would be to use a Flash array where the first element is 0. Danny ___ 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
RE: [Flashcoders] Identifier expected
Thanks everyone for the responses. This thread has been really helpful. - MM ___ 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
RE: [Flashcoders] Identifier expected
>>There's nothing wrong with saying: >> >>var data:Object=new Object(); >>data['a']="something"; >> >>Try it. OK, I see, so then curious why this script returns compiler errors: function createData():Void { this._data = new Object(); this._data["a"] = new Object(); this._data["a"] = {"t1":0, "t2":0}; } createData() trace(this._data.a) Seems to be something wrong with that. Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Ian Thomas >>Sent: Friday, February 09, 2007 2:47 PM >>To: Flashcoders mailing list >>Subject: Re: [Flashcoders] Identifier expected >> >>Uh, Jason. >> >>There's nothing wrong with saying: >> >>var data:Object=new Object(); >>data['a']="something"; >> >>Try it. >> >>Ian >> >>On 2/9/07, Merrill, Jason <[EMAIL PROTECTED]> wrote: >>> That's because you're still not refrencing an object that exists: >>> >>> >>this._data["a"] = new Object(); >>> >>> You're saying, Hey, _data, make your "a" property an object. But >>> Flash is saying, hold on cowboy, I don't see any property >>of _data called "a". >>> >>> >>> So instead: >>> >>> private function createData():Void { >>> this._data = new Object(); >>> this._data.a = new Object(); >>> this._data.a = {"t1":0, "t2":0}; } >>> >>> Or use the one-liner Steve just posted, which is intead, an >>explicit >>> declaration. I use that one commonly. >>> >>> >>> Jason Merrill >>> Bank of America >>> Learning & Organizational Effectiveness >>> >>> >>> >>> >>> >>> >>> >>> >>-Original Message- >>> >>From: [EMAIL PROTECTED] >>> >>[mailto:[EMAIL PROTECTED] On Behalf Of >>> >>Mendelsohn, Michael >>> >>Sent: Friday, February 09, 2007 2:02 PM >>> >>To: Flashcoders mailing list >>> >>Subject: RE: [Flashcoders] Identifier expected >>> >> >>> >>Thanks Jason. I see what you're saying. So I inited an >>object and >>> >>then define it, but the below still errors. I was just >>hoping to be >>> >>able to define my object with only one line of code. >>> >> >>> >>private function createData():Void { >>> >> this._data = new Object(); >>> >> this._data["a"] = new Object(); >>> >> this._data["a"] = {"t1":0, "t2":0}; } >>> >> >>> >> >>> >>I was using new Number for a reason, but it's not >>critical I suppose. >>> >>Thanks Steven. >>> >> >>> >>- Mike >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >>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. In other words, >>> >> >>> >>this._data.a >>> >> >>> >>the .a in the above statement has not been declared or >>identified as >>> >>an object, and thus this._data["a"] resolves to nothing. >>> >>___ >>> >>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 >>> >> >>> ___ >>> 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 >>> >>___ >>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 >> ___ 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
RE: [Flashcoders] Identifier expected
Right, But "a" is not an object. If you follow the thread, you will see that's' what he's trying to do. There IS something wrong with: private function createData():Void { this._data = new Object(); this._data["a"] = new Object(); this._data["a"] = {"t1":0, "t2":0}; } createData() trace(this._data.a) Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Ian Thomas >>Sent: Friday, February 09, 2007 2:47 PM >>To: Flashcoders mailing list >>Subject: Re: [Flashcoders] Identifier expected >> >>Uh, Jason. >> >>There's nothing wrong with saying: >> >>var data:Object=new Object(); >>data['a']="something"; >> >>Try it. >> >>Ian >> >>On 2/9/07, Merrill, Jason <[EMAIL PROTECTED]> wrote: >>> That's because you're still not refrencing an object that exists: >>> >>> >>this._data["a"] = new Object(); >>> >>> You're saying, Hey, _data, make your "a" property an object. But >>> Flash is saying, hold on cowboy, I don't see any property >>of _data called "a". >>> >>> >>> So instead: >>> >>> private function createData():Void { >>> this._data = new Object(); >>> this._data.a = new Object(); >>> this._data.a = {"t1":0, "t2":0}; } >>> >>> Or use the one-liner Steve just posted, which is intead, an >>explicit >>> declaration. I use that one commonly. >>> >>> >>> Jason Merrill >>> Bank of America >>> Learning & Organizational Effectiveness >>> >>> >>> >>> >>> >>> >>> >>> >>-Original Message- >>> >>From: [EMAIL PROTECTED] >>> >>[mailto:[EMAIL PROTECTED] On Behalf Of >>> >>Mendelsohn, Michael >>> >>Sent: Friday, February 09, 2007 2:02 PM >>> >>To: Flashcoders mailing list >>> >>Subject: RE: [Flashcoders] Identifier expected >>> >> >>> >>Thanks Jason. I see what you're saying. So I inited an >>object and >>> >>then define it, but the below still errors. I was just >>hoping to be >>> >>able to define my object with only one line of code. >>> >> >>> >>private function createData():Void { >>> >> this._data = new Object(); >>> >> this._data["a"] = new Object(); >>> >> this._data["a"] = {"t1":0, "t2":0}; } >>> >> >>> >> >>> >>I was using new Number for a reason, but it's not >>critical I suppose. >>> >>Thanks Steven. >>> >> >>> >>- Mike >>> >> >>> >> >>> >> >>> >> >>> >> >>> >> >>> >>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. In other words, >>> >> >>> >>this._data.a >>> >> >>> >>the .a in the above statement has not been declared or >>identified as >>> >>an object, and thus this._data["a"] resolves to nothing. >>> >>___ >>> >>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 >>> >> >>> ___ >>> 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 >>> >>___ >>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 >> ___ 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
Re: [Flashcoders] Identifier expected
Uh, Jason. There's nothing wrong with saying: var data:Object=new Object(); data['a']="something"; Try it. Ian On 2/9/07, Merrill, Jason <[EMAIL PROTECTED]> wrote: That's because you're still not refrencing an object that exists: >>this._data["a"] = new Object(); You're saying, Hey, _data, make your "a" property an object. But Flash is saying, hold on cowboy, I don't see any property of _data called "a". So instead: private function createData():Void { this._data = new Object(); this._data.a = new Object(); this._data.a = {"t1":0, "t2":0}; } Or use the one-liner Steve just posted, which is intead, an explicit declaration. I use that one commonly. Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Mendelsohn, Michael >>Sent: Friday, February 09, 2007 2:02 PM >>To: Flashcoders mailing list >>Subject: RE: [Flashcoders] Identifier expected >> >>Thanks Jason. I see what you're saying. So I inited an >>object and then define it, but the below still errors. I was >>just hoping to be able to define my object with only one line of code. >> >>private function createData():Void { >> this._data = new Object(); >> this._data["a"] = new Object(); >> this._data["a"] = {"t1":0, "t2":0}; >>} >> >> >>I was using new Number for a reason, but it's not critical I suppose. >>Thanks Steven. >> >>- Mike >> >> >> >> >> >> >>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. In other words, >> >>this._data.a >> >>the .a in the above statement has not been declared or >>identified as an object, and thus this._data["a"] resolves to nothing. >>___ >>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 >> ___ 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 ___ 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
RE: [Flashcoders] Identifier expected
That's because you're still not refrencing an object that exists: >>this._data["a"] = new Object(); You're saying, Hey, _data, make your "a" property an object. But Flash is saying, hold on cowboy, I don't see any property of _data called "a". So instead: private function createData():Void { this._data = new Object(); this._data.a = new Object(); this._data.a = {"t1":0, "t2":0}; } Or use the one-liner Steve just posted, which is intead, an explicit declaration. I use that one commonly. Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Mendelsohn, Michael >>Sent: Friday, February 09, 2007 2:02 PM >>To: Flashcoders mailing list >>Subject: RE: [Flashcoders] Identifier expected >> >>Thanks Jason. I see what you're saying. So I inited an >>object and then define it, but the below still errors. I was >>just hoping to be able to define my object with only one line of code. >> >>private function createData():Void { >> this._data = new Object(); >> this._data["a"] = new Object(); >> this._data["a"] = {"t1":0, "t2":0}; >>} >> >> >>I was using new Number for a reason, but it's not critical I suppose. >>Thanks Steven. >> >>- Mike >> >> >> >> >> >> >>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. In other words, >> >>this._data.a >> >>the .a in the above statement has not been declared or >>identified as an object, and thus this._data["a"] resolves to nothing. >>___ >>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 >> ___ 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
RE: [Flashcoders] Identifier expected
private function createData():Void { this._data = {a:{t1:0, t2:0}}; } One line. :) > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Mendelsohn, Michael > Sent: Friday, February 09, 2007 11:02 AM > To: Flashcoders mailing list > Subject: RE: [Flashcoders] Identifier expected > > Thanks Jason. I see what you're saying. So I inited an > object and then define it, but the below still errors. I was > just hoping to be able to define my object with only one line of code. > > private function createData():Void { > this._data = new Object(); > this._data["a"] = new Object(); > this._data["a"] = {"t1":0, "t2":0}; > } > > > I was using new Number for a reason, but it's not critical I suppose. > Thanks Steven. > > - Mike > > > > > > > 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. In other words, > > this._data.a > > the .a in the above statement has not been declared or > identified as an object, and thus this._data["a"] resolves to nothing. > ___ > 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 > ___ 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
RE: [Flashcoders] Identifier expected
Thanks Jason. I see what you're saying. So I inited an object and then define it, but the below still errors. I was just hoping to be able to define my object with only one line of code. private function createData():Void { this._data = new Object(); this._data["a"] = new Object(); this._data["a"] = {"t1":0, "t2":0}; } I was using new Number for a reason, but it's not critical I suppose. Thanks Steven. - Mike 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. In other words, this._data.a the .a in the above statement has not been declared or identified as an object, and thus this._data["a"] resolves to nothing. ___ 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
RE: [Flashcoders] Identifier expected
*can't use* {:} -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Bianchi Sent: Friday, February 09, 2007 10:25 AM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] Identifier expected 2 issues: 1) identifiers are an expression not a string ie a:"hey" vs "a":"hey". The later will not work 2) You can not use a number as identifier in this case. The compiler catches it and throws an error. However, you can hack it using this[1] = "hello world"; trace(this[1]); but then you can use {:} type syntax. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: Friday, February 09, 2007 10:09 AM To: Flashcoders mailing list Subject: [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 ___ 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 ___ 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
RE: [Flashcoders] Identifier expected
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. In other words, this._data.a the .a in the above statement has not been declared or identified as an object, and thus this._data["a"] resolves to nothing. Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Mendelsohn, Michael >>Sent: Friday, February 09, 2007 1:09 PM >>To: Flashcoders mailing list >>Subject: [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 >> ___ 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
RE: [Flashcoders] Identifier expected
> 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]); -- 5 Works for me. You must be doing something else wrong. I'm not sure why you're using new Number(). I don't think I've ever used that. Ever. ___ 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
RE: [Flashcoders] Identifier expected
2 issues: 1) identifiers are an expression not a string ie a:"hey" vs "a":"hey". The later will not work 2) You can not use a number as identifier in this case. The compiler catches it and throws an error. However, you can hack it using this[1] = "hello world"; trace(this[1]); but then you can use {:} type syntax. -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mendelsohn, Michael Sent: Friday, February 09, 2007 10:09 AM To: Flashcoders mailing list Subject: [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 ___ 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
Re: [Flashcoders] Identifier expected
As you have discovered you are not able to use numbers as keys in line objects. Trying to do what you do will however not change this. Only way to do what you want would be to insert the indexes manually: function createObj():Void { this._data = new Object(); this._data["a"] = new Object(); this._data["a"][1] = new Number(0) } Mendelsohn, Michael wrote: 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 ___ 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