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 various different types of content that can be created with using Adobe Flash and Autodesk Scaleform such as:

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 cover this subject matter in extensive depth. 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 is included in the Scaleform SDK/inc folder which is part 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 their documentation here.

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. Common examples include when the movie is being played from a browser or is being 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 data and receive data directly to and from Prepar3D. The most familiar, as well as most useful, functions are the VarGet and VarSet which allow the developer to access Prepar3D's parameters. These functions will be the most utilized when creating Scenario Content and Panels And Gauges Content.

For help on any of the available methods, see Prepar3D.as in the Scaleform SDK/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 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. Else 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 ScaleformPanel to display this type of Adobe Flash content. Defining a ScaleformPanel will not position the panel on screen. Use the OpenPanelAction to open the panel in addition to defining or modifying its:

The ClosePanelAction can close the ScaleformPanel 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 ScaleformPanels 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 SDK at the following location: Scaleform SDK/ui/MenuWindow.

Example

An example of using ScaleformPanel and ScaleformObject is available in the Scenario SDK and is called:

Tic-Tac-Toe Example

Creating Panels and Gauges Content

Gauges now have the ability to programmed using Adobe Flash and integrated into Prepar3D with Autodesk Scaleform.

The basic process for creating a Scaleform Panel or Gauge is as follows:

  1. Create and publish the Flash Content according to the directions listed above.
  2. Place the Adobe Flash SWF movie file in the same folder as the panel.cfg for a given SimObject.
  3. Add the SCALEFORM_FILE property (whose value should be the aforementioned Adobe Flash SWF movie file name including extension) to a [WINDOW] or [VCOCKPIT] entry in the panel.cfg
  4. Optionally, add these properties for more configuration of the Scaleform content:

    • SCALEFORM_INSTANCE_NAME
    • SCALEFORM_RTT_ELEMENT_00 to SCALEFORM_RTT_ELEMENT_NN

An example gauge can be found in the SDK at the following location: Scaleform SDK/Samples/HeadingGauge.fla

See Panel Configuration Files for more information on these Scaleform specific properties.

Additionally, see Using the Prepar3D Interface to learn how to develop Adobe Flash panels and gauges content that integrate with Prepar3D to display and set relevant data. For more information on programming gauges, see the article on Programmable Gauges.

Theme Existing User Interface Content

Examples of the existing Scaleform content used in Prepar3D can be found in the SDK at the following location: Scaleform SDK/ui.