Detect Flash Player Version; Install/Upgrade if necessary

Posted on 2006-11-14
Last Modified: 2012-08-14
I've seen this asked and answered a number of different ways, but I can't make any of the examples work for myself. I need to:
1) Detect the user's Flash Player version
2) Express Install/Upgrade to new version if necessary
3) Ensure that Dreamweaver's JavaScript Active Content workaround is in place (no click/space bar to use controls)
4) Begin playing the SWF

None of Adobe's Flash Player Detection Kit instructions or example files seem to work at all for me - let alone accomplishing all of the above. I know many of you probably do this every day. Would someone please please help?? I'm "just a designer..." :)

My current code, taken from the published Flash8 HTML file, is included below. Let me know if you need any other information. Thanks!!

<!-- saved from url=(0013)about:internet -->
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/javascript">
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->
<script language="VBScript" type="text/vbscript">
<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
Function VBGetSwfVer(i)
  on error resume next
  Dim swControl, swVersion
  swVersion = 0
  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
  if (IsObject(swControl)) then
    swVersion = swControl.GetVariable("$version")
  end if
  VBGetSwfVer = swVersion
End Function
// -->
<script language="JavaScript1.1" type="text/javascript">
<!-- // Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
      // NS/Opera version >= 3 check for Flash plugin in plugin array
      if (navigator.plugins != null && navigator.plugins.length > 0) {
            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                  var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                  descArray = flashDescription.split(" ");
                  tempArrayMajor = descArray[2].split(".");
                  versionMajor = tempArrayMajor[0];
                  versionMinor = tempArrayMajor[1];
                  if ( descArray[3] != "" ) {
                        tempArrayMinor = descArray[3].split("r");
                  } else {
                        tempArrayMinor = descArray[4].split("r");
                  versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
            } else {
                  flashVer = -1;
      // MSN/WebTV 2.6 supports Flash 4
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
      // WebTV 2.5 supports Flash 3
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
      // older WebTV supports Flash 2
      else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
      // Can't detect in all other cases
      else {
            flashVer = -1;
      return flashVer;
// If called with no parameters this function returns a floating point value
// which should be the version of the Flash Player or 0.0
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
       reqVer = parseFloat(reqMajorVer + "." + reqRevision);
         // loop backwards through the versions until we find the newest version      
      for (i=25;i>0;i--) {      
            if (isIE && isWin && !isOpera) {
                  versionStr = VBGetSwfVer(i);
            } else {
                  versionStr = JSGetSwfVer(i);            
            if (versionStr == -1 ) {
                  return false;
            } else if (versionStr != 0) {
                  if(isIE && isWin && !isOpera) {
                        tempArray         = versionStr.split(" ");
                        tempString        = tempArray[1];
                        versionArray      = tempString .split(",");                        
                  } else {
                        versionArray      = versionStr.split(".");
                  versionMajor      = versionArray[0];
                  versionMinor      = versionArray[1];
                  versionRevision   = versionArray[2];
                  versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                  versionNum        = parseFloat(versionString);
              // is the major.revision >= requested major.revision AND the minor version >= requested minor
                  if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                        return true;
                  } else {
                        return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );      
      return (reqVer ? false : 0.0);
// -->
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<script language="JavaScript" type="text/javascript">
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if(hasRightVersion) {  // if we've detected an acceptable version
    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width="250" height="230"'
    + 'codebase="">'
    + '<param name="movie" value="bcam_video.swf" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
    + '<embed src="bcam_video.swf" loop="false" quality="high" bgcolor="#ffffff" '
    + 'width="250" height="230" name="bcam_video" align="middle"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'pluginspage="">'
    + '<\/embed>'
    + '<\/object>';
    document.write(oeTags);   // embed the flash movie
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here.'
        + 'This content requires the Macromedia Flash Player.'
         + '<a href=>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
// -->
      // Provide alternate content for browsers that do not support scripting
      // or for those that have scripting disabled.
        Alternate HTML content should be placed here. This content requires the Macromedia Flash Player.
        <a href="">Get Flash</a>        
Question by:slovisa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
LVL 17

Expert Comment

by:Dushan De Silva
ID: 17944624
1.) File --> Publish Settings --> HTML --> Template --> select "Detect for Flash 6"

Assisted Solution

Jakob_E earned 250 total points
ID: 17945689

Have a look at SWFObject - It does all you want :)

Jakob E


Author Comment

ID: 17956009
Dushan, I have tried to publish withe the Detect option checked, but it doesn't accomplish all of the above goals.

Jakob, this sounds like the perfect solution, but I haven't been able to make it work. Maybe I'm over-simplifying it - I simply added this to the header:
<!-- SWFObject embed by Geoff Stearns -->
<script type="text/javascript" src="swfobject.js"></script>

Then added this where my Flash object goes:
      <div id="flashcontent">
            This content requires the Macromedia Flash Player.<br />
            <a href="">Click here to Get Flash.</a>

      <script type="text/javascript">
            // <![CDATA[
            var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8.0.0", "#FFFFFF", true);
            // ]]>

(And of course added the swfobject.js file to my server)

That's not working for me at all. What am I doing wrong?
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.


Author Comment

ID: 17962557
If anyone can tell me how to implement SWFObject to:
1) Detect the user's Flash Player version
2) *Express Install/Upgrade* to new version if necessary
3) *Display alternate content* to users who can't Express Install
3) Begin playing the SWF, *including the active content workaround* (no click/space bar to use controls)

The points are all yours. Please help!

Expert Comment

ID: 17964663

Have you looked at the expressinstall.html and flashversion.html
both included in the zip file... They works on my pc (ie + firefox)

~ Jakob

Author Comment

ID: 17966326
Yes. Here's exactly what I've done:

1) Copied to my header:
<script type="text/javascript" src="swfobject.js"></script>

2) Copied to the body, where my swf should appear:
<div id="flashcontent">
This page requires the Macromedia Flash Player.<br>
<a href="" target="_blank">Get Flash</a>
<script type="text/javascript">
   var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8", "#FFFFFF");

3) Copied to the first frame of my SWF (no other content on frame 1):
#include ""

// initialize the ExpressInstall object
var ExpressInstall = new ExpressInstall();

// if the user needs to upgrade, show the 'start upgrade' button
if (ExpressInstall.needsUpdate) {

     // this is optional, you could also automatically start the
     // upgrade by calling ExpressInstall.init() here instead of the following lines

     // attach the custom upgrade message and center it
     var upgradeMsg = attachMovie("upgradeMsg_src", "upgradeMsg", 1);
     upgradeMsg._x = Stage.width / 2;
     upgradeMsg._y = Stage.height / 2;

     // attach the button actions that will start the ExpresInstall updater
     upgradeMsg.upgradeBtn.onRelease = function() {
          // the ExpressInstall.init() method is what kicks off the actual update
     // if expressinstall is invoked, stop the timeline.

4) Copied and swfobject.js to my web server.

The results: I get a big blank box in IE6, and I get the alternate content in Firefox - And I have Player9 installed...

Any idea what I'm doing wrong? Thanks for your help.
LVL 11

Expert Comment

ID: 17994664
try like this. The script must reside inside the flashcontent.

<div id="flashcontent">
This page requires the Macromedia Flash Player.<br>
<a href="" target="_blank">Get Flash</a>

<script type="text/javascript">
   var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8", "#FFFFFF");

Author Comment

ID: 17995619
The SWFObject embed alone seems to work whether the JS is inside or outside the DIV, since it's targeting the DIV anyway. Adding the Express Install is where I'm running into trouble.
LVL 11

Expert Comment

ID: 17995742
Well yesterday i installed it following these instructions and it worked out. So should work for you to.
LVL 11

Accepted Solution

ch2 earned 250 total points
ID: 17995767
Also make sure to read the notes like next one:

It's important to not place any content on the first frame (or wherever your ExpressInstall check happens) that requires Flash player 7 or higher.

Author Comment

ID: 18324826
Ultimately the SWFObject solution was implemented correctly, but the swf was missing a stop action on the final frame...

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question