EDIT I just found that Senocular did much the same thing so I guess that means it’s ok…
http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/KeyObject.as
I am curious about using numerals as variable names in objects.
I am not sure how to explain this but the code below shows what I mean:
var o:Object=new Object();
o['123']=true;// so is kinda an equivalent to 'o.123' ??
trace(o['123']);//true
//trace(o.123);//1084: Syntax error: expecting rightparen before .123.
o['abc']=true;
trace(o.abc);//true //works fine of course
trace(o['abc']);//true
so as long as I put my reference in square brackets [] is there any drawback from using numerals as variable names?
The reason I was wondering about this is because I am using a global static object and then assigning keyCodes to it eg:
private function KD(e:KeyboardEvent):void
{
Keys.KO[e.keyCode]=true;
}
where Keys is my global class and KO is my object and I can just check say
if(Keys.KO['65']==true)trace('key a is down');
and yes I know I could always concat with a letter eg
Keys.KO['k'+e.keyCode]=true;
but I would still like to understand it all…
thank you for your consideration,
S.