- 注册时间
- 2013-10-14
- 最后登录
- 2013-12-16
- 阅读权限
- 20
- 积分
- 132
- 精华
- 0
- 帖子
- 44
|
function base(d, b, a){
b.apply(d, a);
var p = null,
o;
for (p in b.prototype) {
o = d.constructor.prototype;
if (!o[p]) o[p] = b.prototype[p];
o[p][SUPER] = b.prototype;
}
}
这种实现方法会导致基类构造函数中对基类本身声明的函数调用时报错:
TypeError: this.setItemRendererBuilder is not a function),
因为传递到基类构造函数中的 this 对象,一开始只具备了子类本身声明的方法与属性,而未具备基类声明的方法。
改成
function base(d, b, a){
var p = null,
o;
for (p in b.prototype) {
o = d.constructor.prototype;
if (!o[p]) o[p] = b.prototype[p];
o[p][SUPER] = b.prototype;
}
b.apply(d, a);
}
就不会出现错误
还有事件的传导方式,如LSprite 的方法 mouseEvent 其实还有一种更好的方式来实现冒泡,并且实现 actionScript 3.0 顶层 LSprite 对象屏蔽底层鼠标感应的方法。
|
|