private function init():void {
//新建对象
var obj:Object = new Object();
//增加key-value
obj["name"] = "liguoliang"; //格式: Object[key] = value
obj["age"] = 25; //注意: key必须为String, value可以为任意类型
//使用for..in...遍历所有的key - value
for(var k:String in obj) {
trace("Key: " + k + " - value: " + obj[k]);
}
//使用for each..in遍历HashMap
for each( var v:* in obj) {
trace("value: " + v);
}
//删除一个key-value
delete obj["age"];
//使用for..in...遍历所有的key - value
for(var k:String in obj) {
trace("Key: " + k + " - value: " + obj[k]);
}
}