Documentation

  Dispatching Events from an animation

Often an animation is not just a set of frames that needs to be played back. Sometimes an animation should trigger some actions inside of your application. The moment to start the action also needs to be configured within the animation. Flash-developers can use Events inside flash-animations and handle them in a flash application using Action Script 3. This easy-to-use approach simplifies development and makes complex things simple. GAF allows other developers use the same approach in their applications on other frameworks/technologies.

How to prepare an animation in Flash Pro

Open FLA file with an animation and find a Movie Clip where you want to insert a trigger. You can insert a trigger into any Movie Clip in any frame. The trigger can also be inserted inside nested Movie Clips at any depth of nesting. After you found an appropriate frame, do the following:

import flash.events.Event;
this.dispatchEvent(new Event("EventName"));

standalone gaf converter

You can use any name for the event. Just change "EventName" to any appropriate name, that easy.

You can also dispatch an event with additional data (if you need to). Additional data is represented as a String and can contain any information you need. Insert the following code in Actions panel to dispatch an event with additional data:

import flash.events.DataEvent;
this.dispatchEvent(new DataEvent("EventName", false, false, "Your additional data"));

standalone gaf converter

 

How to work with Events in runtime

Starling GAF

starling

You can find an example of how to work with Events in Starling GAF library in the custom_events sample in the demo directory.

 

Cocos2D-X v3 GAF

cocos2d-x

You can find an example of how to work with Events in Cocos2D-X GAF library sample in the 'tests' directory. Check 'custom_event.fla' and 'EventsTest' class

 

Cocos2D-JS GAF

unity

You can find an example of how to work with Events in Cocos2D-JS GAF library in the custom_events sample in the demo directory.

 

Unity3d GAF

unity

Example for this library is under development and will be available in the near future.