Object与Dictionary的区别

看看这两端代码就知道了:

object的输出:

var a:Object = new Object();
var b:Object = new Object();
var c:Object=new Object()
var obj:Object = new Object();
obj[a] = 1;// obj["[object Object]"] = 1;    
obj[b] = 2;// obj["[object Object]"] = 2;    
obj[c] = 3;// obj["[object Object]"] = 2; 
for (var prop:String in obj)
{
	trace(prop);// traces: [object Object]    
	trace(obj[prop]);// traces: 2    
}

 Dictionary的输出:

import flash.utils.Dictionary; 

var a:Object = new Object(); 
var b:Object = new Object(); 

var dict:Dictionary = new Dictionary(); 
dict[a] = 1; // dict[a] = 1; 
dict[b] = 2; // dict[b] = 2; 

for (var prop:* in dict) { 
      trace(prop); // traces: [object Object], [object Object] 
      trace(dict[prop]); // traces: 1, 2 
}

 

posted @ 2014-08-12 15:52  Andy.Qiu  阅读(390)  评论(0编辑  收藏  举报