The Menu Kit consists of two parts: the Flash assets that make up the different screens and the C++ code that drives them.
The overall structure of the application consists of game states. A game state is a logical state in the application that provides a discrete set of functionalities. For example, the splash state shows the splash screen and handles appropriate input management. Another example is the loading state which manages the background loading of game data in addition to updating the loading view on screen.
The game states manage lifetimes themselves and register with the main game entity which is responsible for delegating system and user events to the active state. Memory consumption for each state is quarantined within. Releasing a state is expected to free all memory used by that state and its children.
Each state has access to the UI manager, which provides support to display multiple SWFs at the same time, similar to a compositing approach, as well as the resource manager, which provides interfaces to setup SWF loaders, create background data loaders and manage sound banks. The resource manager provides support to create a sound manager, which allows the UI to generate sound events that cause sound samples to be played in turn.
The menu kit demo includes the following states:
The MainMenu is the only interactive state. It provides separate interfaces for communicating between widgets on screen. All main menu sub-screens (views) has a corresponding C++ class. This class keeps a reference via GFx::Value to the SWF file that it loaded, allowing the application to interact with the Flash content dynamically at runtime.
The Flash content for the Menu Kit can be found in the following directory: Scaleform SDK Installation Directory/GFx 4.6/Bin/Data/AS2 or AS3/Kits/Menu
The .FLA and .SWF files can be divided into groups based on the game state where each is used:
The most important file in this directory is MenuAssets.fla which contains all of the components and view layouts for the menu portion of the Menu Kit. The FLA files for the main menu views (e.g. MainMenu.fla, SettingsView.fla, etc…) import all of their content from MenuAssets.fla. This architecture creates a single location for symbols across all views and therefore simplifies updating of assets.
When changing a component or view, the ActionScript class and/or associated symbol should be changed in MenuAssets.fla. After doing so, MenuAssets.swf must be republished. Republishing MenuAssets.swf will cause the other SWF files to be automatically updated, since these SWF files will load the updated content dynamically from MenuAssets.swf at runtime.
Note that the one exception to this rule is SystemUI.swf, which contains all of its own symbol definitions and does not import anything from MenuAssets.swf to avoid loading MenuAssets.swf into memory when the SystemUI.swf is displayed. The system state exists throughout the lifetime of the demo and necessitates a low memory footprint.
The Menu Kit is built using CLIK, included with the Scaleform SDK. All custom CLIK components used in the Menu Kit can be found in the following directory: Scaleform SDK Installation Directory/GFx 4.6/Bin/Data/AS2 or AS3/Kits/Menu/com/scaleform/
The standard CLIK codebase can be found in the following directory: Scaleform SDK Installation Directory/GFx 4.6/Resources/AS2 or AS3/CLIK/
Note that the standard CLIK classpath must be added to your ActionScript 2.0 /3.0 Preferences to republish any of the Menu Kit’s SWF files.
To obtain C++ references to CLIK components, the Menu Kit uses an initialization callback framework. When any CLIK component is first initialized, it attempts to call the function _global.CLIK_initCallback() with its path, name, and reference as parameters. Note that this only occurs if the function is defined in the VM.
_global.CLIK_initCallback() is not defined by default, but can be defined via a function object in C++ using the Direct Access API. When ActionScript invokes the method, the parameters are sent to the C++ function that was assigned as the function object. More information on function objects and the Direct Access API can be found in the Game Communication documentation.
In the case of the Menu Kit, the GameStateWidgetSupport class provides a robust framework that is used to receive and process these CLIK initialization callbacks.