Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Created December 21, 2012 17:16
Show Gist options
  • Save wolframkriesing/4354174 to your computer and use it in GitHub Desktop.
Save wolframkriesing/4354174 to your computer and use it in GitHub Desktop.
imho this shows that dictionary keys are sorted (even in the case of a namespace, as here flash.display there is an order, alphabetcially it seems) and the keys are walked, and if a key that is at the very first position (of that internal order) is added while iterating, it gets NOT visited in the looping. This is bad, i guess that is a bug in t…
/*
imho this shows that dictionary keys are sorted (even in the case of a namespace, as here flash.display
there is an order, alphabetcially it seems) and the keys are walked,
and if a key that is at the very first position (of that internal order) is added while iterating,
it gets NOT visited in the looping.
This is bad, i guess that is a bug in the ActionScript runtime.
It seems there is some comparison that breaks when it's index is 0 ...
let me know if I am wrong
*/
var dict = new Dictionary;
dict[flash.display.ActionScriptVersion] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[flash.display.AVM1Movie] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[flash.display.AVM1Movie] = " + dict[flash.display.AVM1Movie]);
trace("dict[flash.display.ActionScriptVersion] = " + dict[flash.display.ActionScriptVersion]);
trace('======');
var dict = new Dictionary;
dict[flash.display.AVM1Movie] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[flash.display.ActionScriptVersion] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[flash.display.AVM1Movie] = " + dict[flash.display.AVM1Movie]);
trace("dict[flash.display.ActionScriptVersion] = " + dict[flash.display.ActionScriptVersion]);
trace('======');
var dict = new Dictionary;
dict[flash.display.AVM1Movie] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[flash.display.Bitmap] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[flash.display.AVM1Movie] = " + dict[flash.display.AVM1Movie]);
trace("dict[flash.display.Bitmap] = " + dict[flash.display.Bitmap]);
trace('======');
var dict = new Dictionary;
dict[flash.display.Bitmap] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[flash.display.AVM1Movie] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[flash.display.AVM1Movie] = " + dict[flash.display.AVM1Movie]);
trace("dict[flash.display.Bitmap] = " + dict[flash.display.Bitmap]);
trace('======');
var dict = new Dictionary;
dict[0] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[1] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[0] = " + dict[0]);
trace("dict[1] = " + dict[1]);
trace('======');
var dict = new Dictionary;
dict[1] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[0] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[0] = " + dict[0]);
trace("dict[1] = " + dict[1]);
trace('======');
var dict = new Dictionary;
dict[1] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[2] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[1] = " + dict[1]);
trace("dict[2] = " + dict[2]);
trace('======');
var dict = new Dictionary;
dict[2] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[1] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[1] = " + dict[1]);
trace("dict[2] = " + dict[2]);
/*
key = [class ActionScriptVersion]
dict[flash.display.AVM1Movie] = true
dict[flash.display.ActionScriptVersion] = undefined
======
key = [class AVM1Movie]
key = [class ActionScriptVersion]
dict[flash.display.AVM1Movie] = undefined
dict[flash.display.ActionScriptVersion] = undefined
======
key = [class AVM1Movie]
key = [class Bitmap]
dict[flash.display.AVM1Movie] = undefined
dict[flash.display.Bitmap] = undefined
======
key = [class Bitmap]
key = [class AVM1Movie]
dict[flash.display.AVM1Movie] = undefined
dict[flash.display.Bitmap] = undefined
======
key = 0
key = 1
dict[0] = undefined
dict[1] = undefined
======
key = 1
dict[0] = true
dict[1] = undefined
======
key = 1
key = 2
dict[1] = undefined
dict[2] = undefined
======
key = 2
key = 1
dict[1] = undefined
dict[2] = undefined
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment