Quick tip: … (rest) parameter

Here is a quick tip for using … (rest) parameter in your code. It sometimes happens that you want to have your function called multiple times, when different events dispatched or even without any event dispatched. Properly you would create callback/handler functions for all events, that would call the required function. Or you can use … (rest) parameter to bypass arguments casting.

priate function init():void
{
    addEventListener(Event.ENTER_FRAME, doSomething);

    var timer:Timer = new Timer(500);
    timer.addEventListener(TimerEvent.TIMER, doSomething);
    timer.start();

    callLater(doSomething);
    doSomething();
}

private function doSomething(... rest):void
{
// whatever
}
Get Adobe Flash playerPlugin by wpburn.com wordpress themes