Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to detect what version of Flash is installed on a system

Step-by-step tutorial

how to detect what version of Flash is installed on a system

by  DianaCL  Posted    (Edited  )
[color red] Intention of this tutorial: [/color]

to understand how to direct the browser to the page corresponding to the FlashPlayer version the system has installed.


First you need to detect if any version of Flash is on the system. That you can check with a JavaScript. If there is, you can make a swf that detects the version of the Flash player installed and send the browser to a html page that has the content built in that kind of Flash.

--------------
Note:

it is easy to modify the code and make the browser just say what type of flash player the system has.

--------------

Step 1:

detecting wether you have any player for flash:

you make a HTML page and put inside teh following code:
Code:
<HTML>
<HEAD>
<TITLE>Plug-in and ActiveX Detection</TITLE>
<SCRIPT LANGUAGE=JavaScript>
<!--
//Created by Robert Reinhardt for the Flash 5 Bible, IDG Books
//This script will detect the presence of either the plug-in or
//the Active X Control for the Flash 5 Player.

var plugin = 0;
var activeX = 0;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
	plugin = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 5;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('activeX = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
	document.write('<' + '/SCRIPT>');
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF">
<CENTER>
<TABLE WIDTH=450 BORDER=0>
<TR><TD ALIGN=CENTER WIDTH=225>
<SCRIPT LANGUAGE=JavaScript>
<!--
if ( plugin ) {
	document.write('<EMBED SRC="trafficLightGreen.swf" WIDTH="105" HEIGHT="185" SWLIVECONNECT="FALSE" QUALITY="HIGH"></EMBED><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=2>Flash 5 Player<BR>Plug-in detected.</FONT>');
} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)){
	document.write('<A HREF="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
	document.write('<IMG SRC="trafficLightRed.gif" WIDTH="105" HEIGHT="185" BORDER="0"></A><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=2>Flash 5 Player<BR>Plug-in not installed.</FONT>');
}
//-->
</SCRIPT>
</TD>
<TD ALIGN=CENTER WIDTH=225>
<SCRIPT LANGUAGE=JavaScript>
<!--
if (activeX){
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
	document.write(' ID=trafficLightRed WIDTH=105 HEIGHT=185>');
	document.write(' <PARAM NAME=movie VALUE="trafficLightGreen.swf"><PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF></OBJECT><BR>'); 
	document.write(' <FONT FACE="Verdana,Arial,Geneva" SIZE=2>Flash 5 Player ActiveX<BR>Control detected.');
} else {
	document.write('<A HREF="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&P2_Platform=Win32&P3_Browser_Version=MSIE">');
	document.write('<IMG SRC="trafficLightRed.gif" WIDTH="105" HEIGHT="185" BORDER="0"></A><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=2>Flash 5 Player ActiveX<BR>Control not installed.</FONT>');
}
//-->
</SCRIPT>
</TD></TR>
</TABLE>
<SCRIPT LANGUAGE=JavaScript>
<!--
if (plugin == 0 && activeX == 0 && navigator.platform.indexOf("Mac")>=0 && navigator.userAgent.indexOf("MSIE")>=0){
	document.write('<BR><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=3>You are using Internet Explorer 4.5 or earlier on the Macintosh.<BR>');
	document.write('<B>The Flash Player plug-in can not be detected with scripting.</B><BR>');
	document.write('Click the left-hand traffic light to download the plug-in.');
} else if (plugin == 1 || activeX == 1){
	document.write('<BR><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=3><B>You can view Flash content with your browser.</B><BR>');
	document.write('Proceed to the main Flash site.</FONT>');
} else if (plugin == 0 && activeX == 0){
	if(navigator.appName.indexOf("Netscape")>=0){
		playerType = "left";
	} else {
		playerType = "right";
	}
	document.write('<BR><BR><FONT FACE="Verdana,Arial,Geneva" SIZE=3><B>You can not view Flash content with your browser.</B></FONT><BR>');
	document.write('<FONT FACE="Verdana,Arial,Geneva" SIZE=2>Please click the ' + playerType + '-hand traffic light to download the player.</FONT>');
}
//-->
</SCRIPT>
</CENTER>
</BODY>
</HTML>

let's say you call the page flahDetection.html
----------------------
----------------------
step 2:


make a picture and call it trafficSignRed.gif and put it in the same folder as the html.
This is the picture that will appear when you don't have any player.

---------------------
---------------------
step 3:

open Macromedia Flash and make a new movie, trafficSignGreen.fla. The result of this, trafficSignGreen.swf, has to be in the same folder as the html and gif file.

leave the first frame empty and add a new keyframe on frame 2. add the following actionscript to the frame:
Code:
// create a Flash variable, whose value is equal to the
// $version environment variable in Flash 4 or 5. This
// action line will not be read by Flash 3 (or earlier)
// Players.

player = eval("$version");
myOutput = player;

// The $version value will be in the format:
// 
// abc 1,2,3,4
// 
// where abc is the operating system (e.g. WIN, MAC)
// and 1 and 2 are the major version designations
// (e.g. 4.0, 5.0, etc.) and 3 and 4 are the minor version
// designations (e.g. r20, r27, etc.)
// 
// By default, Flash 5 ships with a Player version equal to
// WIN 5,0,30,0 or MAC 5,0,30,0
// 
// We just need the major version designation, at
// placeholder 1. Using substring(), we can extract this
// number. The major version starts at the 5th character of
// the version value. The Flash 3 Player will disregard
// this line.

player = substring(player, 5, 1);

// player will be equal to either 4 or 5 in Flash 4 or 5 Player, respectively.

if (player eq "") {

	// Flash 3 Player will execute this code automatically,
	// because it will need interpret the if action.

	getURL("flash3.html");

} else if (player eq "4") {

	// Flash 4 Player will execute this code.

	getURL ("flash4.html");

} else if (player eq "5") {

	// Flash 5 Player will execute this code.

	getURL ("flash5.html");

}else { getURL ("flash6.html");
}
// We will prevent the movie from accidentally looping.

stop ();
that's all with the swf file.

Note: if you want it just to show what kind of player you have, and not take you to a different file, you have to change the getURL() command to a _root.gotoAndStop() command that goes to a different frame inside the movie for each version of the player. By the way, don't forget to make those frames and add some words or graphics to each frame.

-------------------------
-------------------------
step 4:


Now you have to make the html files for each version of the player.

make a flash3.html, flash4.html, flash5.html, flash6.html.

what's inside these html files is of your own choice.

put them all in the same folder as the swf, the gif and the flashDetect.html

====================
====================

that's about all.
It does work. If you want to check it, go to http://www.migroup.go.ro/swiffer/scriptDetection.html
it will redirect you automatically to the page corresponding to the flash player you have.


Diana. (member name DianaCL)
29 nov. 2002
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top