Checking the user’s Flash Player capabilities using the flash.system.Capabilities class

by Peter deHaan on August 8, 2007

in Capabilities

There are a lot of times when you may want to know what version of the Flash Player plug-in your visitors are using. Or perhaps you want to know their screen resolution, operating system, language, whether they have accessibility or an IME. Finding all this out is simple thanks to the Flash Player’s flash.system.Capabilities class.

The following application will show how you can grab all the capabilities of the user’s Flash Player and display them in an easy-to-read DataGrid control.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">

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

            /* Label function for the nameCol DataGridColumn object. */
            private function nameColFunc(item:Object, column:DataGridColumn):String {
                var ss:String = item.@serverString;
                if (ss.length > 0) {
                    ss = " (" + ss + ")";
                }
                return item.@name + ss;
            }

            /* Label function for the valueCol DataGridColumn object. */
            private function valueColFunc(item:Object, column:DataGridColumn):String {
                return Capabilities[item.@name];
            }
        ]]>
    </mx:Script>

    <mx:XML id="capabilitiesXML" source="capabilities.xml" />

    <mx:ApplicationControlBar dock="true">
        <mx:Label text="Player version: {Capabilities.version} (debug={Capabilities.isDebugger})" />
    </mx:ApplicationControlBar>

    <mx:DataGrid id="dataGrid" width="100%" height="100%" variableRowHeight="true">
        <mx:dataProvider>{capabilitiesXML.property}</mx:dataProvider>
        <mx:columns>
            <mx:DataGridColumn id="nameCol" labelFunction="nameColFunc" headerText="Property name (server string):" />
            <mx:DataGridColumn id="valueCol" labelFunction="valueColFunc" headerText="Value:" wordWrap="true" />
            <!--mx:DataGridColumn id="valueCol" dataField="@value" headerText="Value:" wordWrap="true" /-->
        </mx:columns>
    </mx:DataGrid>

    <mx:ApplicationControlBar>
        <mx:Text width="500">
            <mx:htmlText>&lt;b&gt;Capabilities.serverString:&lt;/b&gt;&llt;br /&gt;{Capabilities.serverString}</mx:htmlText>
        </mx:Text>
    </mx:ApplicationControlBar>

</mx:Application>

View capabilities.xml

<capabilities>
    <property name="avHardwareDisable" serverString="AVD" value="{Capabilities.avHardwareDisable}" />
    <property name="hasAccessibility" serverString="ACC" value="{Capabilities.hasAccessibility}" />
    <property name="hasAudio" serverString="A" value="{Capabilities.hasAudio}" />
    <property name="hasAudioEncoder" serverString="AE" value="{Capabilities.hasAudioEncoder}" />
    <property name="hasEmbeddedVideo" serverString="EV" value="{Capabilities.hasEmbeddedVideo}" />
    <property name="hasIME" serverString="IME" value="{Capabilities.hasIME}" />
    <property name="hasMP3" serverString="MP3" value="{Capabilities.hasMP3}" />
    <property name="hasPrinting" serverString="PR" value="{Capabilities.hasPrinting}" />
    <property name="hasScreenBroadcast" serverString="SB" value="{Capabilities.hasScreenBroadcast}" />
    <property name="hasScreenPlayback" serverString="SP" value="{Capabilities.hasScreenPlayback}" />
    <property name="hasStreamingAudio" serverString="SA" value="{Capabilities.hasStreamingAudio}" />
    <property name="hasStreamingVideo" serverString="SV" value="{Capabilities.hasStreamingVideo}" />
    <property name="hasTLS" serverString="TLS" value="{Capabilities.hasTLS}" />
    <property name="hasVideoEncoder" serverString="VE" value="{Capabilities.hasVideoEncoder}" />
    <property name="isDebugger" serverString="DEB" value="{Capabilities.isDebugger}" />
    <property name="language" serverString="L" value="{Capabilities.language}" />
    <property name="localFileReadDisable" serverString="LFD" value="{Capabilities.localFileReadDisable}" />
    <property name="manufacturer" serverString="M" value="{Capabilities.manufacturer}" />
    <property name="os" serverString="OS" value="{Capabilities.os}" />
    <property name="pixelAspectRatio" serverString="AR" value="{Capabilities.pixelAspectRatio}" />
    <property name="playerType" serverString="PT" value="{Capabilities.playerType}" />
    <property name="screenColor" serverString="COL" value="{Capabilities.screenColor}" />
    <property name="screenDPI" serverString="DP" value="{Capabilities.screenDPI}" />
    <property name="screenResolutionX" serverString="R" value="{Capabilities.screenResolutionX}" />
    <property name="screenResolutionY" serverString="R" value="{Capabilities.screenResolutionY}" />
    <property name="serverString" serverString="" value="{Capabilities.serverString}" />
    <property name="version" serverString="V" value="{Capabilities.version}" />
</capabilities>

View source is enabled in the following example.

{ 3 comments… read them below or add one }

1 peterd October 10, 2007 at 5:12 pm

For another example of checking a user’s system capabilities, check out this site’s “About you” page (view source is enabled, code is actually documented for once too).

Reply

2 Preetam August 26, 2008 at 4:14 am

How could the content of the textArea be shown on the printout covering the whole page???
properties like NONE,MATCH_WIDTH,FILL_PAGE and SHOW_ALL are useless,I can see the whole typed contents but it is not covering the whole page…

Reply

3 Reny Mohan January 30, 2010 at 3:28 am

Hi Peter ,
i’m also facing the same problem. The flexPrintjob is not giving the full content in the print output page.i googled alot, most of the example is for printing dataGrid but i need to print a canvas and its contents. Can you give me some examples that prints a canvas containing custom objects.
pls do reply.
Thanks in advance,

Reny Mohan

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: