Marcelo Noronha
Marcelo Noronha

Reputation: 815

Creating your own ADDED_TO_STAGE event

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.

Upvotes: 0

Views: 121

Answers (1)

Marty
Marty

Reputation: 39456

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);
}

Upvotes: 1

Related Questions