动态类作用主要是根据自己的需要添加自己想要的属性,其中Object就是一个动态类。
下面为动态类属性添加的两种方法:
internal function testObject():void{
var student:Object = new Object();
student.name = "小王";
student.age = 20;
student.type = "本科";
for(var prop:String in student){
trace(prop+":"+student[prop]);
}
}
internal function testObject():void{
var student:Object = new Object();
student["name"] = "小王";
student["age"] = 20;
student["type"] = "本科";
for each(var prop:String in student){
trace(prop);
}
}