Scaleform Game Communication Overview

Interfacing C++, Flash and ActionScript

Flash®’s ActionScript™ scripting language enables creation of interactive movie content. Events such as clicking a button, reaching a certain frame, or loading a movie can execute code to dynamically change movie content, control the flow of the movie, and even launch additional movies. ActionScript is powerful enough to create full mini-games entirely in Flash. Like most programming languages, ActionScript supports variables and subroutines and contains objects which can represent items or controls.

Communicating between the application and the Flash content is required for complex use cases. Autodesk Scaleform® supports the standard mechanisms provided by Flash that enables ActionScript to pass events and data back to the C++ application. It also provides a convenient C++ interface to directly manipulate ActionScript variables, arrays, and objects, as well as directly invoke ActionScript subroutines.

In this document we discuss the different mechanisms that are available when communicating between C++ and Flash. The following are the available options:

ActionScript -> C++ C++ -> ActionScript
FSCommand
Simple, string-based function execution, no return values, deprecated
GFx::Movie::Get/SetVariable
Access data in ActionScript, uses string path
ExternalInterface
Flexible argument handling, supports return values, recommended
GFx::Movie::Invoke
Call functions in ActionScript, uses string path
Direct Access API
Uses GFx::Value as a direct reference to objects for data and function access, high performance. Set direct function callbacks in the ActionScript VM using GFx::FunctionHandler.