Quote Originally Posted by metafurionx View Post
To anyone that ended here looking for a simple solution to a problem like Andreq85's, it does exist:

PHP Code:
var someHandlerFunc:Function = someFunc(someArgs);
myBtn.addEventListener(MouseEvent.CLICKsomeHandlerFunc);
//myBtn.removeEventListener(MouseEvent.CLICK, someHandlerFunc);

function someFunc(someArgs:Object):Function {
    return function(
e:MouseEvent):void {
        
trace(someArgs);
    };

For multiple elements you can do:

PHP Code:
btn1.addEventListener(MouseEvent.CLICKaddPage(1));
btn2.addEventListener(MouseEvent.CLICKaddPage(2));
btn3.addEventListener(MouseEvent.CLICKaddPage(3));

function 
addPage(_nPage:int):Function {
    return function(
e:MouseEvent):void {
        
nPage += _nPage;
    };

Nifty trick for a one-off, and for lazy prototyping, but I think it would be a bit risky for a production system as it makes clean up code rather tough eg: it's rather tough to find a function reference to removeEventListener!

All the same, thanks for some food for thought.