How to detect Flash Player 11 correctly

Posted on:September 22 2011

Adobe just announced the upcoming release of Flash Player 11, which is the one with real, hardware accelerated 3D, code name 'Molehill', now named 'Stage3D'. The demos on the CopperCube website will also soon be replaced with newer, nicer ones, using Stage 3D, and thus, will no longer run on old Flash Players. So it is necessary to add some flash player version detection. I'm not a fan of this, because in a lot of cases, something goes wrong with this detection and although your user would be able to view your content, you are only showing him a 'Update your Flash Player!' message box instead. So instead of doing this, I wanted to simply display a small warning message and then still try to load the content. Like I did here:


Turns out that the famous SWFObject script has a method to detect the version, nice. We only need to call swfobject.getFlashPlayerVersion(), take a look at the major version number of the item returned, and then display or not display the warning. In case you also want to do the same, here is the full code I used to do this:

<div id="flashwarning" style="border: 1px solid #FFD149; background-color:#FFEEB5; width: 80%; padding: 10px 10px 10px 10px; display:none;">
WARNING: <b>This demo requires Flash Player 11. You only have Flash Player version <span id="flashversion">8</span>.</b><br/>
<a href="http://get.adobe.com/flashplayer/">Get the latest Flash Player version from Adobe</a>.<br/>
</div><br/>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
  var playerVersion = swfobject.getFlashPlayerVersion();
  var playerVersionStr = playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release;
  if (playerVersion.major < 11)
  {
    var warningElem = document.getElementById("flashwarning");
    if (warningElem)
    flashwarning.style.display = "block";
    var versionElem = document.getElementById("flashversion");
    if (versionElem)
      versionElem.innerHTML = playerVersionStr;
  }
</script>



Add comment:


Posted by:


Enter the missing letter in: "Internationa?"


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons