Monday, July 23, 2007

Determining Flash Player version in Flex

To determine which version of Flash Player you are currently using--the standard version or the debugger version--you can use the Capabilities class. This class contains information about Flash Player and the system that it is currently operating on. To determine if you are using the debugger version of Flash Player, you can use the isDebugger property of that class. This property returns a Boolean value: the value is true if the current player is the debugger version of Flash Player and false if it is not.

The following example uses the playerType, version, and isDebugger properties of the Capabilities class to display information about the Player:
<?xml version="1.0"?>

<!--
logging/CheckDebugger.mxml -->
<
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<
mx:Script><![CDATA[
import
flash.system.Capabilities;

private function
reportVersion():String {
if
(Capabilities.isDebugger) {

return
"Debugger version of Flash Player";
}
else {
return
"Flash Player";
}
}

private function
reportType():String {

return
Capabilities.playerType + " (" + Capabilities.version + ")";
}
]]></
mx:Script>

<
mx:Label text="{reportVersion()}"/>
<
mx:Label text="{reportType()}"/>

</
mx:Application>


Other properties of the Capabilities class include hasPrinting, os, and language.

No comments: