Apr
11
2009

 

There are times when you might want to iterate through and display the capabilities of the Flash Player.  This snippet will do that:

[c]import flash.display.Sprite;
import flash.system.Capabilities;
import flash.utils.describeType;

public function getSystemInfo():void
{
	var capability:XML=describeType(Capabilities);
	//trace(capability);
	var capabilities:XMLList=capability.children();
	for each (var xmlData:XML in capabilities)
	{
		if (xmlData.@name && Capabilities[xmlData.@name])
			trace(xmlData.@name+"="+Capabilities[xmlData.@name]);
	}
}[/c]

The output is something like this:

hasPrinting=true
hasScreenPlayback=true
screenDPI=72
_internal=1
os=Windows Vista
hasAccessibility=true
hasMP3=true
version=WIN 9,0,159,0
screenResolutionY=1050
hasEmbeddedVideo=true
manufacturer=Adobe Windows
hasVideoEncoder=true
pixelAspectRatio=1
hasAudio=true
screenResolutionX=1680
hasTLS=true
isDebugger=true
screenColor=color
hasStreamingVideo=true
serverString=A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=...
language=en
hasAudioEncoder=true
playerType=PlugIn
hasStreamingAudio=true
prototype=[object Object]

About the Code

We cannot use for each … in iterator because the properties are static.   So we use  flash.utils.describeType() function which returns an XML object containing the properties of the object.  You can see the XML output here: Capabilities.xml

We then iterate through every children nodes, we check to print only the nodes that contains a name attribute.  You can modify the function to return the capabilities on an Array if desired.

Comments are closed.