0

Is it possible to create your own ADDED_TO_STAGE event?

I´m trying to pass some arguments to its handler...

It would be like this:

addEventListener(Event.ADDED_TO_STAGE, arg1, arg2, init)

There´s any workaround for this?

Thanks.

Marcelo Noronha
  • 807
  • 2
  • 12
  • 26
  • 2
    http://stackoverflow.com/questions/6406957/how-to-pass-arguments-into-event-listener-function-in-flex-actionscript/6407128#6407128 – Marty Apr 27 '12 at 02:08

1 Answers1

1

Visiting this link will provide an in-depth answer on this, however here's a quick and dirty snapshot:

A function called by a listener can only have one argument, which is the event triggering it.

You will need to either call another function from your listener function, or create a custom event to hold the properties you want to parse. The latter is recommended, but here's how you could implement the former:

function init(e:Event):void
{
    removeEventListener(Event.ADDED_TO_STAGE, init);

    finalize(arg1, arg2);
}


function finalize(a:*, b:*):void
{
    trace(a, b);
}
Community
  • 1
  • 1
Marty
  • 39,033
  • 19
  • 93
  • 162