Solved

Flash detection using getVersion

Posted on 2006-11-15
11
364 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now