User Guide
Example: Detecting system capabilities 445
CapabilitiesExplorer overview
The CapabilitiesExplorer.mxml file is responsible for setting up the user interface for the
CapabilitiesExplorer application. The user’s Flash Player capabilities will be displayed within a
DataGrid component instance on the Stage. Their browser capabilities will also be displayed if
they are running the application from an HTML container and if the External API is
available.
When the main application file’s
creationComplete event is dispatched, the initApp()
method is invoked. The
initApp() method calls the getCapabilities() method from
within the com.example.programmingas3.capabilities.CapabilitiesGrabber class. The code for
the
initApp() method is as follows:
private function initApp():void
{
var dp:Array = CapabilitiesGrabber.getCapabilities();
capabilitiesGrid.dataProvider = dp;
}
The CapabilitiesGrabber.getCapabilities() method returns a sorted array of the Flash
Player and browser capabilities, which then gets set to the
dataProvider property of the
capabilitiesGrid DataGrid component instance on the Stage.
CapabilitiesGrabber class overview
The static getCapabilities() method of the CapabilitiesGrabber class adds each property
from the flash.system.Capabilities class to an array (
capDP). It then calls the static
getBrowserObjects() method in the CapabilitiesGrabber class. The
getBrowserObjects() method uses the External API to loop over the browser’s navigator
object, which contains the browser’s capabilities. The
getCapabilities() method is as
follows:
public static function getCapabilities():Array
{
var capDP:Array = new Array();
capDP.push({name:"Capabilities.avHardwareDisable",
value:Capabilities.avHardwareDisable});
capDP.push({name:"Capabilities.hasAccessibility",
value:Capabilities.hasAccessibility});
capDP.push({name:"Capabilities.hasAudio", value:Capabilities.hasAudio});
...
capDP.push({name:"Capabilities.version", value:Capabilities.version});
var navArr:Array = CapabilitiesGrabber.getBrowserObjects();
if (navArr.length > 0)
{
capDP = capDP.concat(navArr);