更新时间:12/13/2004 9:08 PM
var log1 = new LoginClass("rerd");
trace(log1.getUserName());
//out.print:rerd
trace(log1.userName);
//out.print:rerd
userName1_txt.text = log1.userName;
//文字框显示rerd
//userName和getUserName()都是private,但仍然可以访问???
//
var log2:LoginClass = new LoginClass("rerd");
userName2_txt.text = log2.userName;
trace(log2.getUserName());
trace(log2.userName);
/**
产生如下编译错误,而且log1 相关的userName1_txt也无法显示值 log1.userName???
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 39: The member is private and cannot be accessed.
trace(log2.getUserName());
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 40: The member is private and cannot be accessed.
trace(log2.userName);
Total ActionScript Errors: 2 Reported Errors: 2
*/
真的是很难理解啊!可能是因为严格数据类型指定时数据类型不匹配会触发编译器错误.在帮助中有这样一句话“还应注意成员访问控制是一个仅限于编译时的功能;在运行时,Flash Player 不区分私有或公共成员”这样就不难理解为什么会出现这种情况了