To anyone that ended here looking for a simple solution to a problem like Andreq85's, it does exist:
For multiple elements you can do:PHP Code:var someHandlerFunc:Function = someFunc(someArgs);
myBtn.addEventListener(MouseEvent.CLICK, someHandlerFunc);
//myBtn.removeEventListener(MouseEvent.CLICK, someHandlerFunc);
function someFunc(someArgs:Object):Function {
return function(e:MouseEvent):void {
trace(someArgs);
};
}
PHP Code:btn1.addEventListener(MouseEvent.CLICK, addPage(1));
btn2.addEventListener(MouseEvent.CLICK, addPage(2));
btn3.addEventListener(MouseEvent.CLICK, addPage(3));
function addPage(_nPage:int):Function {
return function(e:MouseEvent):void {
nPage += _nPage;
};
}




Reply With Quote