var CustomerAge:int=65;
var CustomerName:String="Jane Doe";
//I want to convert the above to keep but I can't specify the datatype for each child object
var UserProfile:Object = new Object();
UserProfile.CustomerAge:int=64;
UserProfile.CustomerName:string="Jane Doe";
The below is works but I can't specify the datatype
var UserProfile:Object = new Object();
UserProfile.CustomerAge=64;
UserProfile.CustomerName="Jane Doe";
任何想法的人?
答案 0 :(得分:1)
如果在将元素添加到对象时声明元素类型会怎样?
例如:
var UserProfile:Object = new Object();
UserProfile.CustomerAge = new int(64);
UserProfile.CustomerName = new String("Jane Doe");
希望它有所帮助, 罗布
答案 1 :(得分:0)
如果要强制执行类型,则应使用类而不是Object。查看本教程:http://www.adobe.com/devnet/flash/quickstart/creating_class_as3.html