If you paste this code into the constructor of a document class in Flash CS3 and put a breakpoint on the third line from the bottom you’ll see really weird things happening to the object o in the variables window:
var o:Object = {};
o["0"] = "Hello World";
o["1"] = "Hello World";
o["2"] = "Hello World";
o["3"] = "Hello World";
o["4"] = "Hello World";
o["5"] = "Hello World";
o["6"] = "Hello World";
o["7"] = "Hello World";
o["8"] = "Hello World";
o["9"] = "Hello World";
o[""] = "Hello World";
o["_"] = "Hello World";
o["!"] = "Hello World";
o["#"] = "Hello World";
o["$"] = "Hello World";
o["%"] = "Hello World";
o["'"] = "Hello World";
o["("] = "Hello World";
o[")"] = "Hello World";
o["*"] = "Hello World";
o["+"] = "Hello World";
o[","] = "Hello World";
o["-"] = "Hello World";
o["."] = "Hello World";
o["/"] = "Hello World";
o[":"] = "Hello World";
o[";"] = "Hello World";
o["="] = "Hello World";
o[">"] = "Hello World";
o["?"] = "Hello World";
o["@"] = "Hello World";
o["["] = "Hello World";
o["\\"] = "Hello World"; // Escape
o["]"] = "Hello World";
o["^"] = "Hello World";
o["`"] = "Hello World";
o["{"] = "Hello World";
o["|"] = "Hello World";
o["}"] = "Hello World";
o["~"] = "Hello World";
// Put breakpoint on next line and step through the next 3 lines
o["<"] = "Hello World"; // All values starting from o[";"] are gone
o["&"] = "Hello World"; // All values starting from o["%"] are gone
o["\""] = "Hello World"; // All values starting from o["!"] are gone
Can anyone explain why this happens. If the code in the last three lines is not legal, why doesn’t the runtime throw an error? And is this per the ecma specifications, or documented elsewhere?
Thanks for any clarifications!
Not sure what is happening ( I didn’t try the code. );
Instead of an object, have you tried using a Dictionary object;
var o : Dictionary = new Dictionary();
o[ “1” ] = “Whatever…”;
Thanks for your reply. It does not matter if you use Dictionary or any other class. You see, it’s a language facility that allows you to add key/value pairs to any object. In fact, if you try it with a MovieClip, all the movieclip properties such as x, y, etc will disappear from the variables view during debugging when I step into the third line from the bottom. I don’t know about you, but I find that more than a little weird.
Please try the code, you can just copy paste it, it would only take 3 minutes and would really help me out a lot. Because I have no reference, there’s no documentation or any description of this as far as I know. I tried the ecma documents but that’s really hard to read.
What I’d like to know is:
- Does the same thing happen to other people?
- Is this considered normal?
- If not, is it a bug, and is there a status on it?
- If it’s by design, where can I read about it in specs or documentation?
Again, thanks for your reply, and please try the code, thanks!
I tried it with an untitled, unsaved document, and got the same results. There’s apparently no effect when not debugging. It’s probably a bug, and although it’s interesting, there’s not much we can conclude about Flash hashing from this.
If you’re interested in the way that Flash’s VM handles things like hash tables, you might try your luck perusing through the Tamarin source. But hashing is supposed to be one of those things that Flash encapsulates for you, so there’s not much documentation really.
Hey thanks for trying. You are right, it’s actually only a bug in the Flash authoring environment.