Solved

Flash detection using getVersion

Posted on 2006-11-15
11
368 Views
Last Modified: 2011-10-03
Hi.

I have a setup that uses a page with a swf to determine wheather or not the user has the right Flash version or not and then re-direct them accordingly. When I tested locally changing my parameters for the required version it all worked fine, but when I switched to live testing it does not work the way it should. I think maybe I've done something wrong with the logical operators but then again they should be tha same no matter if you run locally or not.

This is my setup:
index.html - runs the swf that checks the Flash version
main.html - if the requirements are fulfilled go here
flash-update.html - if the requirements lack go here

http://www.andreasgustavsson.com/ee

This is my actionscript:

/* Detect the user's operating system platform and
Flash Player version and then break that info down into
usable variables and [arrays]*/

//Get system info and make string lower case
vSystemInfo = getVersion().toLowerCase();
//Break string into usable pieces
vTempString1 = vSystemInfo.split(",", 1);
vTempString2 = vTempString1[0].split(" ", 2);
//Extract Platform
vPlatform = vTempString2[0];
//Extract Major Version eg. 8
vVersionMajor = vTempString2[1];
//Extract Minor Version eg. (8).0.22.0
vVersionMinor = vSystemInfo.split(",", 4);

//Set minimum conditions
vWinMajorMin = 8;
vWinMinorMin1 = 0;
vWinMinorMin2 = 20;
vWinMinorMin3 = 0;

vMacMajorMin = 8;
vMacMinorMin1 = 0;
vMacMinorMin2 = 20;
vMacMinorMin3 = 0;

vUnixMajorMin = 9;
vUnixMinorMin1 = 0;
vUnixMinorMin2 = 0;
vUnixMinorMin3 = 0;

//Compare results and redirect to correct html page
if (vPlatform == "win") {
      if (vVersionMajor >= vWinMajorMin && vVersionMinor[1] >= vWinMinorMin1
            && vVersionMinor[2] >= vWinMinorMin2 && vVersionMinor[3] >= vWinMinorMin3) {
            getURL("main.html", "_self");
      } else getURL("flash-update.html", "_self");
}

if (vPlatform == "mac") {
      if (vVersionMajor >= vMacMajorMin && vVersionMinor[1] >= vMacMinorMin1
            && vVersionMinor[2] >= vMacMinorMin2 && vVersionMinor[3] >= vMacMinorMin3) {
            getURL("main.html", "_self");
      } else getURL("flash-update.html", "_self");
}

if (vPlatform == "unix") {
      if (vVersionMajor >= vUnixMajorMin && vVersionMinor[1] >= vUnixMinorMin1
            && vVersionMinor[2] >= vUnixMinorMin2 && vVersionMinor[3] >= vUnixMinorMin3) {
            getURL("main.html", "_self");
      } else getURL("flash-update.html", "_self");
}

I hope that someone can help me with a quick sollution to this, will reward 500 points.

Cheers,
Andreas.
0
Comment
Question by:iamcmag
  • 5
  • 4
11 Comments
 
LVL 5

Expert Comment

by:blockage1
ID: 17955446
The quick solution would be to use SWFObject instead. http://blog.deconcept.com/swfobject/

This can also enable express install and will fix the IE active-x activation bug.

The only downside is users need javascript - but users who turn that off probably dont care about flash anyway.
0
 

Author Comment

by:iamcmag
ID: 17974439
Hi blockage1.

That is one way to do it and it's maybe even a better way. I will look into using this technique later, however right now I want get my current script working and not switch to using another technique. I'm still looking for an answer to the question at hand.

Please testrun the page and have a look at the script.

/Andreas
0
 
LVL 5

Expert Comment

by:blockage1
ID: 17979650
I don't have flash on the machine I'm on right now so I can test this but... I'm pretty sure when you use split() you end up with an array of strings - you might need to recast the results to Numbers before you can evaluate them.
0
Independent Software Vendors: 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!

 

Author Comment

by:iamcmag
ID: 17986791
I've sorted it myself. There were problems with my logical comparison of the users version and the specified parameters, I'd overlooked several possibilities. The values works fine as variables though, no problems to compare them as integers. Everything works fine now.

/Andreas
0
 
LVL 5

Expert Comment

by:blockage1
ID: 17987677
Next time then. good luck,
b
0
 

Author Comment

by:iamcmag
ID: 17987734
No worries!

Script revision:

/* Detect the user's operating system platform and
Flash Player version and then break that info down into
usable variables and [arrays]*/

//Get system info and make string lower case
vSystemInfo = getVersion().toLowerCase();
//Break string into usable pieces
vTempString1 = vSystemInfo.split(",", 1);
vTempString2 = vTempString1[0].split(" ", 2);
//Extract Platform
vPlatform = vTempString2[0];
//Extract Major Version eg. 8
vVersionMajor = vTempString2[1];
//Extract Minor Version eg. (8).0.22.0
vVersionMinor = vSystemInfo.split(",", 4);

//Set minimum conditions
vWinMajorMin = 8;
vWinMinorMin1 = 0;
vWinMinorMin2 = 20;
vWinMinorMin3 = 0;

vMacMajorMin = 8;
vMacMinorMin1 = 0;
vMacMinorMin2 = 20;
vMacMinorMin3 = 0;

vUnixMajorMin = 9;
vUnixMinorMin1 = 0;
vUnixMinorMin2 = 0;
vUnixMinorMin3 = 0;

//Compare results and redirect to correct html page
if (vPlatform == "win") {
      if ((vVersionMajor > vWinMajorMin) || (vVersionMajor >= vWinMajorMin && vVersionMinor[1] > vWinMinorMin1)
            || (vVersionMajor >= vWinMajorMin && vVersionMinor[1] >= vWinMinorMin1) && (vVersionMinor[2] > vWinMinorMin2)
            || (vVersionMajor >= vWinMajorMin && vVersionMinor[1] >= vWinMinorMin1) && (vVersionMinor[2] >= vWinMinorMin2)
            && (vVersionMinor[3] >= vWinMinorMin3)) {
            getURL("main.html", "_self");
      } else
      getURL("flash-update.html", "_self");
}

if (vPlatform == "mac") {
      if ((vVersionMajor > vMacMajorMin) || (vVersionMajor >= vMacMajorMin && vVersionMinor[1] > vMacMinorMin1)
            || (vVersionMajor >= vMacMajorMin && vVersionMinor[1] >= vMacMinorMin1) && (vVersionMinor[2] > vMacMinorMin2)
            || (vVersionMajor >= vMacMajorMin && vVersionMinor[1] >= vMacMinorMin1) && (vVersionMinor[2] >= vMacMinorMin2)
            && (vVersionMinor[3] >= vMacMinorMin3)) {
            getURL("main.html", "_self");
      } else
      getURL("flash-update.html", "_self");
}

if (vPlatform == "unix") {
      if ((vVersionMajor > vUnixMajorMin) || (vVersionMajor >= vUnixMajorMin && vVersionMinor[1] > vUnixMinorMin1)
            || (vVersionMajor >= vUnixMajorMin && vVersionMinor[1] >= vUnixMinorMin1) && (vVersionMinor[2] > vUnixMinorMin2)
            || (vVersionMajor >= vUnixMajorMin && vVersionMinor[1] >= vUnixMinorMin1) && (vVersionMinor[2] >= vUnixMinorMin2)
            && (vVersionMinor[3] >= vUnixMinorMin3)) {
            getURL("main.html", "_self");
      } else
      getURL("flash-update.html", "_self");
}

Maybe someone else can find this script useful. By adding an additional JS to the HTML page that checks for Flashplayer this works quite well for most situations. The only thing missing is the auto update feature.

Regards,
Andreas.
0
 
LVL 5

Expert Comment

by:blockage1
ID: 18011766
I'm happy
0
 

Author Comment

by:iamcmag
ID: 18011800
To blockage1, I asked Community Support to give you 200 points for your quick input even though it was not the final sollution, it seems lika a good technique I did not know about. However I'm not sure that they can.

Regards,
Andreas.
0
 
LVL 5

Expert Comment

by:blockage1
ID: 18011848
Thanks Andreas
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18027766
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

749 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