Using Autodesk® Scaleform® to integrate Adobe® Flash® content with Prepar3D®


Contents
Related Links

Overview

Prepar3D integrates with Autodesk Scaleform to enable developers to leverage the power of the Adobe Flash tool set to create powerful and interactive content for Prepar3D. There are many different types of content that can be created using Adobe Flash and Autodesk Scaleform such as:

SDK Structure

The materials needed to get started integrating Adobe Flash with Prepar3D can be found here:

Lockheed Martin\SDK\Panels Gauges User Interface\panels_and_user_interface\scaleform
Inside are the following subfolders, which will be referenced in later sections:


Creating Adobe Flash Content

The article will not go into detail on how to create content in Adobe Flash because there are many resources available (e.g. books, online reference materials, etc.) that extensively cover this subject. However, please note that Prepar3D requires the flash movie to be published in the Adobe Flash SWF file format before using any of the subsequent methods of importing Adobe Flash content into Prepar3D using Autodesk Scaleform.

To interact with Prepar3D from a flash movie, the Prepar3D Interface will need to be imported. The following section describes how to import the Prepar3D Interface.

Importing the Prepar3D Interface

The Prepar3D Interface can be found in the inc subfolder of the Scaleform folder of the SDK. The interface consists of the following files:

Both interface files must be discoverable by the Flash Development Environment. There are multiple ways of accomplishing this such as:

To learn how to set source paths in Adobe Flash Professional, visit Adobe's documentation.

The Prepar3D Interface has default stub implementations for each of its functions. This allows the movie to behave more appropriately when the flash movie utilizing the Prepar3D Interface is not running in Prepar3D, such as when the movie is being played from a browser or debugged in a Flash Development Environment.

At runtime, the Prepar3D Interface version is read and then interface functions are replaced with native functions that communicate with Prepar3D directly. If functions in the Prepar3D Interface are needed on the first frame of the movie, the Prepar3D Interface must be initialized first. Below is the ActionScript code required to import and initialize the Prepar3D interface:

import Prepar3D
Prepar3D.Init()

If functions from the Prepar3D Interface are not needed in the first frame, then the interface will initialize itself after the first frame. Prepar3D will respect the Prepar3D Interface's Version variable. Care should be taken not to modify this variable as the interface will update and Prepar3D will respect backwards compatibility with older versions.

Using the Prepar3D Interface

The Prepar3D Interface allows for developers to send and receive data directly to and from Prepar3D. The most familiar, as well as most useful, functions are VarGet and VarSet which allow the developer to access Prepar3D's parameters. These functions will be the most utilized when creating Scenario Content and Panel Content.


For further information on any of the available methods, see Prepar3D.as in the inc folder.

Importing RTT Camera Views

To use a RTT Camera View in a Scaleform flash file, follow these directions:

See Panel Configuration Files for more information on setting the SCALEFORM_RTT_ELEMENT property.


Creating Scenario Content

SimDirector contains objects that are specifically designed to import the Adobe Flash SWF file format to deliver an interactive experience.

Resolving Scaleform Content for Scenarios

For scenario content, Prepar3D will try to resolve the referenced Adobe Flash SWF file using the following rules:
  1. If file path is an absolute path Then:
    1. Try to resolve file path using the absolute file path
  2. If file path is a relative path Then:
    1. Try to resolve file path using scenario resource path directory
    2. Try to resolve file path using the configured Scaleform content directories.

Creating Scenario Screen Content

The scenario designer may want to adorn content on the screen that will appear at a defined position in screen space regardless of where the user is looking. Examples of this type of content include:

Use the ScaleformPanelWindow to display this type of Adobe Flash content. Defining a ScaleformPanelWindow will not position the panel on screen, but will specify some its states when it is opened. Use the OpenWindowAction to open the panel in addition to specifying its size and position. The below properties can be used to configure a ScaleformPanelWindow. Size, position, and monitor are properties of the OpenWindowAction while the rest are properties of the ScaleformPanelWindow itself.

The CloseWindowAction can close the ScaleformPanelWindow if the need arises to hide the content from the user.

Creating Scenario World Content

The scenario designer may want to add interactive content to the world that appears at a static or dynamic world position. Examples of this type of content include:

Use the ScaleformObject to display this type of Adobe Flash content. The object's Activated property will control whether or not the movie is visible at its placed location. This can be toggled on and off using an ObjectActivationAction.

Shared and Separate Movie Instances

Adobe Flash SWF Movie instances can be shared between multiple ScaleformPanelWindows or ScaleformObjects if they are using the same file path and InstanceName string identifier. Conversely, if the same movie will be reused multiple times but different content is desired inside of each movie, then utilize different InstanceNames.

Creating Adobe Flash Menu Prompt Content

The in-game MenuPromptTrigger can be overridden with a customized version using Adobe Flash by setting the FlashFileName field. The following functions from the Prepar3D Interface should be used to implement the in-game Menu Prompt functionality:

An example can be found in the subfolder MenuWindow located in the ui folder.

Example

An example of using ScaleformPanelWindow and ScaleformObject is available in the Scenario Samples and is called:

Tic-Tac-Toe Example

Panel Content

To utilize Adobe Flash content in a panel, view the Scaleform Panel Content article.

Theme Existing User Interface Content

Examples of the existing Scaleform content used in Prepar3D can be found in the ui folder.