Requirements
Prerequisite knowledge
Familiarity with Adobe AIR, HTML, JavaScript, and CSS is recommended.
User Level
All

 
Introduction

Adobe’s AIR technology has made it possible for developers around the world to create some of the best and most stunning mobile games available today. You can now use this versatile technology to take your games to a much larger audience. Adobe AIR’s new Game Preview feature  (for Android platform only) lets users try your game and experience it first hand, thereby making their purchasing decision much easier. While several game reviews and ratings are readily available, a preview offers users the advantage of making a choice based on their personal preferences.
 
The Game Preview feature is not restricted to games built on AIR but is available to all developers, irrespective of the technology that you may use to build your application. The fact that the AIR runtime is installed on more than 50 million devices, greatly multiplies the chances of your game being previewed and subsequently installed by game enthusiasts. Besides the wide customer base that it has built over the years, Adobe values its users’ security and ensures that only verified and trusted applications are made available to its customers. By using Adobe AIR to run your game preview, you not only reach more users but also enjoy the trust associated with the company’s products.
 
View our sample in an Android browser to see what a preview running on AIR, looks like:
 
Note: This feature is supported only on mobile devices with the Android platform.
 

 
Hosting Game Previews

To use the Game Preview feature, send a preview of your game in the SWF file format, to Adobe. The SWF file is hosted on Adobe’s secure servers. You can then provide a link to the SWF file, from your web page, to take users to the preview.
 
Preview launched from user’s browser
Figure 1
 
Figure 1 is an example of a preview being launched from the user’s browser. Clicking Preview prompts the user to install AIR, if not already installed. See Figure 2.
 
Clicking Preview prompts the user to install AIR
Figure 2
 
The preview, made available as a SWF file, runs on Adobe AIR. When the preview is complete, users who want to install the full version of the game are directed to the Google Play Store. See Figure 3. Adobe tracks page view statistics for internal monitoring purposes. A free beta version of the feature is currently available to all game developers.
 
Install option when the preview is complete
Figure 3
 

 
Configuring and testing

To ensure that your game preview is being launched correctly and to verify that you have all the required assets, you can test the preview on your internal servers. When hosted on a non-Adobe server, the game preview displays a watermark indicating that you are working in the Debug mode. If required, you can use the sample project available with this article to debug issues with the SWF file.
 
 
Assets
You need the following assets to begin setting up a preview for your game:
 
  • The Game Preview in the SWF file format (the minimum version requirement is SWF 23) with a maximum size of 5 MB.
  • Icon and image files that are displayed when the SWF file is being downloaded. Before passing the image parameter to the game preview URL, ensure that your webpage can identify the best icon size for the target device.
  • The application identifier of the game on the Google Play Store.
 
SWF file configuration
  • The stage API cannot be accessed within the constructor of the SWF that is loaded at runtime. You will need to wait for the Event.ADDED_TO_STAGE event to occur before referring to the stage property in your code:
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; public class GamePreviewExample extends Sprite { public function GamePreviewExample() { super(); addEventListener(Event.ADDED_TO_STAGE, yourCode); } protected function yourCode(event:Event):void { // write your code that uses stage here stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; } } }
  • Only the StageScaleMode.NO_SCALE property is supported for game previews. Any other scale mode may cause the SWF to display incorrectly.
  • The SWF file should be able to resize itself according to the screen size of the device. The lower section of the screen (50-pixels high) is reserved for use by Adobe. Apart from the reserved space, the entire screen is available to the game preview.
  • Ensure that no ads are included as part of the game preview.
  • Do not include any direct links to the Google Play Store to promote game installations. The screen space reserved by Adobe includes an Install Now button that takes users to the Google Play Store.
  • Ensure that all the assets used by the preview are embedded within the SWF file.
 
AIR Runtime detection
Game previews only work on devices that have AIR installed on them. Adobe provides the JavaScript files needed to detect whether AIR is installed on a device. If AIR is installed, the game preview is launched else the user is prompted to install AIR from the Google Play Store.
 
To detect AIR Runtime installation:
 
  1. Import the following JavaScript and CSS files:
    <script src="http://code.jquery.com/jquery-2.0.3.min.js">
     

    <script src="http://dh8vjmvwgc27o.cloudfront.net/prod/gamepreview1/scripts/DetectAIR.js"></script>
     

    <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
     
     
     
    <link type="text/css" rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
     
     
     
    Ensure that you always use DetectAIR.js file from the earlier mentioned location. Developers are prohibited from copying the DetectAIR.js file to their computers for use on their web page.
     
  2. Attach an onclick listener to a button or a link, to listen for the onGamePreviewClicked(url:'<game preview url>') function. See the following code snippet to attach the listener to a button:
    <button onclick="onGamePreviewClicked({url:'www.adobe.com/gamepreview/?swf=game1/game.swf&img=game1/game.png&aspectRatio=landscape&autoorients=true&app=com.air.xyz.com'})">Preview Now</button>
     
Note: Users with 2.3 OS devices have the option of selecting the Don't show this again checkbox to prevent the AIR installation dialog prompt from being displayed. The Don't show this again checkbox is reset when cookies are deleted. If displayed, the AIR installation dialog prompt fades away after 45 seconds, on the assumption that the user has either closed the dialog or is getting AIR installed.
 
 
Launch URL
To launch your game preview, use the appropriate parameters with their respective values in your URL. The preview can be launched as follows:
 
gamepreview://www.xyz.com/?swf=air_example/preview.swf&img=air_example/previewIcon.png&app=air.example
 
xyz.com is an illustrative example of the website from which the preview is launched. When the game preview is invoked, the image and SWF files are downloaded from the following locations:
 
image = www.xyz.com/air_example/previewIcon.png
 
swf = www.xyz.com/air_example/preview.swf
 
Every game may require a different set of values for the aspectratio, autoorients and depthAndStencil properties. You can pass values for the optional properties as follows:
 
gamepreview:/www.xyz.com/?swf=air_example/preview.swf&img=air_example/previewIcon.png&app=air.example&aspectratio=landscape&autoorients=false&depthAndStencil=true
 
The parameters are optional (except swf, img, and app) and position independent.
 
 
SWF Debugging
Download the sample project, GamePreviewTester.zip, available with this article if you need to debug your game preview. To begin debugging, change the value of the swfUrl parameter in the GamePreviewTester.as file and point it to your remote SWF file:
 
private var swfUrl:String = <path of the game swf to be debugged>
 
 
Game Preview Debugging
To detect any issues with the game preview URL, you can use the optional debug paramter whose value can be set to either true or false. Error reporting is enabled when debug is set to true:
 
gamepreview:/www.xyz.com/?swf=air_example/preview.swf&img=air_example/previewIcon.png&app=air.example&aspectratio=landscape&autoorients=false&depthAndStencil=true&debug=true
 
Figure 4 illustrates an example of the error displayed when an application parameter is not used in the game preview URL.
 
Error : application parameter is not used in the game preview URL
Figure 4
 
The Debug mode watermark is not displayed for SWF files hosted on www.adobe.com.
 
 
Publishing
Contact Adobe when your game preview has been set up and is ready for publishing.
 
To publish your game preview:
 
  1. Send the game preview SWF file and the image files to Adobe.
  2. The SWF and image files are hosted on an Adobe server. You will receive the path to the SWF and image file locations.
  3. Update your web page to point to the new file locations on the Adobe server. Game Previews hosted on Adobe’s servers will not display the Debug mode watermark.
You can also choose to pubilicize your game preview by including a link, on the application description page, in the Google Play Store.
 
Contact us if you are interested in partnering with Adobe to help your games reach more users.