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:
- Scenario Content: Adobe Flash can prove useful as a powerful presentation technology when delivering interactive instructional content or displaying rich media content. SimDirector now allows scenario creators to play Adobe Flash content in both screen space and world space using Autodesk Scaleform.
- Panels And Gauges Content: Creating gauges using Adobe Flash content instead of traditional methods (XML, C++, DirectX) is now possible.
- Theme Existing User Interface Content: Prepar3D ships with the original flash source files, in the Scaleform SDK, for UI components that are integrated using Autodesk Scaleform. This allows developers to design their own version of the Application Menu, Context Menu, ATC, or InfoGen.
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.
The Prepar3D Interface is included in the Scaleform SDK/inc folder which is part of the SDK. The interface consists of the following files:
- Prepar3D.as: This is the main interface developers should import from their ActionScript.
- Prepar3DInterface.as: This is an interface wrapper that is imported by Prepar3D.as, but does not need to be directly imported by developers.
Both interface files must be discoverable by the Flash Development Environment. There are multiple ways of accomplishing this such as:
- Adding the absolute or relative path of the Scaleform SDK/inc directory to the Flash Development Environment source paths at the Application Level. This will allow the Prepar3D Interface to be seen by all ActionScript files.
- Adding the absolute or relative path of the Scaleform SDK/inc directory to the Flash Development Environment source paths at the Document Level. This will allow the Prepar3D Interface to be seen by the ActionScript file specifying these settings.
- Copying all of the Prepar3D Interface ActionScript files from Scaleform SDK/inc to the same directory as your flash source files.
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:
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.Scenario Content and Panels And Gauges Content.
For help on any of the available methods, see Prepar3D.as in the Scaleform SDK/inc folder.RTT Camera View in a Scaleform flash file, follow these directions:
- Create or import a bitmap into the desired flash editable project file (*.fla).
NOTE: Auto-resizing of the rendered view into the bitmap does not occur. Therefore, the recommended size of the bitmap is the same as the size defined in the RTT View.
- Specify the linkage string in the Library Window to match a Camera Name that is defined as a SCALEFORM_RTT_ELEMENT property.
For instance, if the Camera Name is 'Radar' then SCALEFORM_RTT_ELEMENT_00 could be defined as 'Radar'. The bitmap linkage should be set to 'Radar' if the developer desires the bitmap to update with the 'Radar' Camera View.
SimDirector contains objects that specifically designed to import the Adobe Flash SWF file format to deliver an interactive experience.
- If file path is an absolute path Then:
- Try to resolve file path using the absolute file path
- Else file path is a relative path Then:
- Try to resolve file path using scenario resource path directory
- Try to resolve file path using the configured Scaleform content directories.
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:
- Displaying the current objective
- Checklist manuals
- Lesson plans
- Docked State: Whether the panel is docked inside of the specified window or has its own window to host it.
- Locked State: If docked, whether the panel can be moved around by the user or is fixed.
- Window: If multiple windows are defined, the window that the panel should appear on can be specified.
- Size: An absolute size, size as a percentage of the window, or combination of these is available.
- Position: An absolute position, position offsets as a percentage of the window, or combination of these is available.
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:
- Virtual Screen displaying Departures and Arrivals
- Arrows, highlights, or other annotations
- Non-Cockpit Instrumentation
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.
- Material Options: Customize the Prepar3D material used for the Adobe Flash movie.
- Flash File Resolution: Determine the resolution that the Adobe Flash movie is created at. Depending on how large the content will be at runtime, the scenario designer can configure the resolution.
- Minimum and Maximum Screen Sizes: It is possible to constrain world content to not grow beyond or shrink past a defined screen size.
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:
- SetMenuPromptOption: Calling this function will execute the Actions associated with the MenuItem at this index.
- GetMenuPromptOptionCount: Get number of MenuItems this MenuPrompt has.
- GetMenuPromptOption: Get the text for the MenuItem at a given index.
- GetMenuPromptPrompt: Get the MenuPrompt text.
- GetWindowTitle: Get the window title.
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:
- Create and publish the Flash Content according to the directions listed above.
- Place the Adobe Flash SWF movie file in the same folder as the panel.cfg for a given SimObject.
- 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
- Optionally, add these properties for more configuration of the Scaleform content:
- 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.