Return to Starling Playback Library

Dispatch Event from some frame

Questions related to Starling playback library should be asked here.

Dispatch Event from some frame

Postby dvrbear » December 22nd, 2014, 2:26 am

Does it real what in new GAF we can dispatch costume events?

Can you give some example for Frame code and Listener code?
User avatar
dvrbear
 
Posts: 26
Joined: October 20th, 2014, 1:42 am

Re: Dispatch Event from some frame

Postby vadym.mitin » December 22nd, 2014, 3:42 am

Hi,

Frame code
Code: Select all
this.dispatchEvent(new Event("CustomEvenName", true, false));

or
Code: Select all
this.dispatchEvent(new DataEvent("CustomEvenName", true, false, "Your custom data here"));


The listener code
Code: Select all
gafMC.addEventListener("CustomEvenName", doSomeAction);

function doSomeAction(event: starling.events.Event): void
{
        trace(event.type); // should be "CustomEvenName"
        trace(event.data); // should be "Your custom data here" in case with DataEvent
};

But please note that this example works only for SWF converted in conversion mode NESTING.

If you will convert SWF in conversion mode PLAIN - GAF Converter will skip this code in frames.
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Re: Dispatch Event from some frame

Postby anton » April 28th, 2015, 1:56 am

Does this event fires also from nested clips? Looks like not. Event is bubbling, but I cannot catch it
User avatar
anton
 
Posts: 47
Joined: February 9th, 2015, 7:20 am

Re: Dispatch Event from some frame

Postby anton » April 28th, 2015, 2:15 am

doesn't work for me at all.
Cannot catch an event
User avatar
anton
 
Posts: 47
Joined: February 9th, 2015, 7:20 am

Re: Dispatch Event from some frame

Postby vadym.mitin » April 28th, 2015, 4:32 am

You should assign the event listener directly to the gafMC from which the event should be dispatched. Bubbling is not working with those events.
User avatar
vadym.mitin
 
Posts: 254
Joined: December 4th, 2013, 8:00 am

Return to Starling Playback Library

Who is online

Users browsing this forum: No registered users and 2 guests