Skip to content

unic8 Studios

Documentations Tutorials FAQs Links Advanced search
You are here: Home arrow News arrow Browse archive
Detecting Flash Player capabilities using describeType()
Monday, 21 January 2008

I'm working on a solid bug reporting functionality for G-Nero and stumbled over the AS3 package flash.system.Capabilities and tried the "good old way" (AS2 alike) and got no result at all. So I did the new style attempting to access the properties (screenDPI, hasAccessibility, ...) via a "for each" loop and... I failed. Adobe itself got an article on LiveDocs containing an example which uses an array of the properties you would like to query. Because this is not really flexible and not very usable for future versions of Flash Players I decided to try it with the new method: describeType()

Adobe's example

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);
  }
  capDP.sortOn("name", Array.CASEINSENSITIVE);
  return capDP;
}

New style with describeType()-method

var flashPlayerData:Array = new Array();
var objectType:XML = describeType(flash.system.Capabilities);
var excludedProperties:Array = ["_internal", "serverString", "prototype"];

for each(var objectProperties:XML in objectType.accessor){
  var propertyName:String = objectProperties.@name;
  var isExcluded:Boolean = false;

  for(var c:uint = 0; c < excludedProperties.length; c++){
    var excludedName:String = excludedProperties[c];
      if(propertyName == excludedName){
        isExcluded = true;
          break;
      }
  }

  if(!isExcluded){
    var propertyValue:String = flash.system.Capabilities[propertyName];
    flashPlayerData.push({name: propertyName, value: propertyValue});
  }
}

flashPlayerData.sortOn("name", Array.CASEINSENSITIVE);

I think this is a good sample where the new method come to it's best.

Trackback(0)
Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

security image
Write the displayed characters


busy
 
< Prev   Next >

Polls

Which data exchange technology do you prefer?