作为一名 Flash 开发人员,我尝试拥有与 AS3 提供的 mootools 相同的灵活性。
我尝试做一件简单的事情,创建一个受保护的事件处理函数。我讨厌写内联函数,所以我写了这样的东西:
//CLASS DEFINITION AS USUAL
initializeEvent:function (){
if (this.options.slider) this.options.slider.addEvents ({
mousedown:function (e){
this.sliderDownHandler();
//throw an error because sliderDownHandler is set to protected
}
});
},
update:function (){
this.fireEvent('update');
}.protect(),
sliderDownHandler:function (e){
this.update();
console.log ('yeah it down')
}.protect();
没有 .protect() 处理程序按预期工作。
使用 .protected() 可以达到这个目标吗?
多谢!