Detecting the Flash Lite version on a device
Flash Lite allows you to check the supported Flash Lite version during runtime. This is useful, for example, if you need to make sure that a device supports the Flash Lite version required by your application, or if your application uses customized functionality for different Flash Lite versions. Once the supported version is known, the application can proceed accordingly.
Note: The Flash Lite version for which you publish your application in the Flash IDE determines which Flash Lite Players can run the application. In general, Flash Lite applications are compatible with their primary version and newer. In other words, Flash Lite 2.x applications can be run on devices that support Flash Lite 2.0 or newer, while Flash Lite 3.x applications can be run on devices that support Flash Lite 3.0 or newer. Flash Lite 1.1 applications can be run on any device that supports Flash Lite. Naturally, if your application uses features that are specific to a given version, the application may not work properly in a previous version of the same primary version. For example, a Flash Lite 3.1 application can be run on a device that only supports Flash Lite 3.0, but the application will not work as intended if it uses features introduced in Flash Lite 3.1.
To detect the Flash Lite version:
1.
Retrieve the Flash Lite version information:
*
If your application requires Flash Lite 2.0 or newer, use either the global getVersion() method or the System.capabilities.version property to retrieve the version.
The following ActionScript 2.0 code snippet uses the getVersion() method to retrieve the version:
var version:String = getVersion();
The following ActionScript 2.0 code snippet uses the System.capabilities.version property to retrieve the version:
var version:String = System.capabilities.version;
*
If you are creating a Flash Lite 1.1 application, use the $version property to retrieve the version:
var version = $version;
Each of these returns the same string value for a given Flash Lite version. For example, in the case of Flash Lite 3.0, the returned value can be:
FL 8,1,56,0
2.
Map the returned value to the correct Flash Lite version.
The returned value is based on the underlying Flash Player version, so you need to map it to the corresponding Flash Lite version. The following table shows the correct mapping. The first number in the returned value is the major version, while the second number is the minor version. For example, the major version number for Flash Lite 3.0 is 8 (Flash Player 8) and the minor version number is 1.
Table: Flash Lite versions and returned version values
Flash Lite version
Returned value range
Example value
Flash Lite 3.1
FL 9,1,X,X
FL 9,1,2,255
Flash Lite 3.0
FL 8,1,X,X
FL 8,1,56,0
Flash Lite 2.1
FL 7,2,X,X
FL 7,2,501,0
Flash Lite 2.0
FL 7,1,X,X
FL 7,1,501,0
Flash Lite 1.1
FL 5,2,X,X
FL 5,2,12,0
Once the supported Flash Lite version is known, program the application to behave accordingly. For example, if the device does not support the required Flash Lite version, program the application to exit. If, on the other hand, the device does support the required version, the application can proceed normally.
The following ActionScript 2.0 code snippet checks that the supported Flash Lite version is 3.1 or newer. If the check fails, the application exits.
// Retrieve the supported Flash Lite version
var version:String = getVersion();
// Extract the major version number, which is
// the fourth character (index position 3) in
// the version string
var majorVersion:String = version.charAt(3);
// If the major version is less than or equal to 8,
// the supported Flash Lite version is 3.0 (FL 8,1,X,X)
// or earlier, in which case the check fails
if (majorVersion <= "8") {
// Set the error message and allow the user to exit the application
errorMessage.text = "You need Flash Lite 3.1 or newer to run this application. Please update your device software, if possible.";
gotoAndPlay("EXIT");
} else {
// Start the application
gotoAndPlay("START");
}
The above code snippet assumes the following:
*
The application is published as Flash Lite 3.1.
*
There is a frame labelled EXIT for exiting the application if the device does not supported the required Flash Lite version. This frame contains a dynamic text field named errorMessage for displaying the error message. The frame does not contain content that requires Flash Lite 3.1.
*
There is a frame labelled START for starting the actual application if the device supports the required Flash Lite version.
*
The code snippet is located in the first frame of the main timeline and is the first piece of content executed when the application is run. The first frame does not contain content that requires Flash Lite 3.1.
*
The major version number for the supported Flash Lite version is a single digit.