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:
- 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.
- Panel Content: Creating panels using Adobe Flash content is now possible instead of traditional panels which have gauges designed in XML, C++, or DirectX.
- Theme Existing User Interface Content: Prepar3D ships with the original flash source files 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 materials needed to get started integrating Adobe Flash with Prepar3D can be found here:
- assets contains individual control components that can be reused to build a user interface.
- inc contains the interfaces and helper classes needed to integrate Adobe Flash content with Prepar3D functionality.
- Samples contains Adobe Flash content that showcase Prepar3D integration using the interfaces and helper classes available in the include folder.
- ui contains the Adobe Flash content for Scaleform UIs found in Prepar3D.
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.
- 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 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 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 the inc directory 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, 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:
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 Panel Content.
For further information on any of the available methods, see Prepar3D.as in the inc folder.
- 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 are 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
- If 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 main Prepar3D 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.
- Can Close State: If docked, whether the panel can be closed by the user.
- Z Order: Determines the order of how the panel should appear.
- Monitor: If multiple monitors are available, the monitor that the panel should appear on can be specified.
- Size: An absolute size, size as a percentage of the main window, or a combination of these is available.
- Position: An absolute position, position offsets as a percentage of the window, or a 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 below 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.
Scaleform Panel Content article.