//本例 obj[key]=xxx。 通过xxx获取key。
var myObject:Object = {PlayerName:"LaoCao", age:27, city:"Liaoning"};
for (var name in myObject) {
if (typeof (myObject[name]) == "string")
//当Object带Key关键字 的 属性值为“String” 的 ,本例有【LaoCao和Liaoning】
{
trace("I have a string property named "+name);
}
}
/*** 控制台 输出
I have a string property named PlayerName
I have a string property named city
***/
for (var name in myObject) {
if (typeof (myObject[name]) == "string")
//当Object带Key关键字 的 属性值为“int” 的 ,本例有【age】
{
trace("I have a int property named "+name);
}
}
/*** 控制台 输出
I have a int property named age
***/