- 或者看起来如此。对AS3词典感到困惑。我有这个:
map = new Dictionary();
map["someKey"] = 1;
我尝试以两种方式打印出来:
for each( var key:Object in d ) {
trace( key + ": " + d[key] );
}
这会打印1: undefined
for each( var o:Object in d ) {
var key:String = o.toString();
var val:int = d[o];
trace( key + ": " + val );
}
这会打印1: null
我希望它出现在someyKey: 1
。我只是打错了吗?
答案 0 :(得分:1)
如Efficient looping through AS3 dictionary所示,你以错误的方式循环播放它。你应该这样做:
for ( var key:Object in d ) {
trace( key + ": " + d[key] );
}