Need Help: Conditional Statement Syntax based on Exact Flash Player Version

76 views
Skip to first unread message

RFX

unread,
Apr 25, 2012, 3:40:44 PM4/25/12
to SWFObject
Hi,
I have a situation where i need to document.write text or display code
based on exact browser version.
For example, if the user's SWFObject detects flash installed player
version 10.3.181 or less then the web page would display the text or
code based on that users exact flash player version.
The code below is something i tried to write that would be compatible
in IE,FireFox,Safari and etc but my syntax is not correct because it
does not work at all.

Could someone help point me in the right direction?
<code>
<html>
<head>
<title>DISPLAY TEXT BASED ON FLASH VERSION</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>

</head>
<body>
<script type="text/javascript">
swfobject.registerObject("myFlashContent", "10.3.181");
if(myFlashContent < 10,3,181)
{
document.write("You have less than 10.3.181");
}
else
{
document.write("CONGRATULATIONS you have equal to or Greater than
10.3.181");
}
</script>
</body>
</html>
</code>
Or any script that would accomplish the same thing with document.write
would be helpful.
Please advise... thanks in advance.

Aran Rhee

unread,
Apr 25, 2012, 4:13:14 PM4/25/12
to swfo...@googlegroups.com
Best look through the docs to see what a method actually returns :) swfobject.registerObject() does not return a version string for you to evaluate. You are looking for the api method:

swfobject.hasFlashPlayerVersion(versionStr)


or if you want more fine grain control:

swfobject.getFlashPlayerVersion()


Both methods can be found on : http://code.google.com/p/swfobject/wiki/api


e.g.
if (swfobject.hasFlashPlayerVersion("10.3.181")) {
 
// has Flash
}
else {
 
// no Flash
}

You do not need to embed an actual swf file for calling either of these methods, just include swfobject.js before calling.


Cheers,
Aran


--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.


RFX

unread,
Apr 25, 2012, 5:48:56 PM4/25/12
to SWFObject
Ah.... i think i see... thank you for the reply....
So how would i change the syntax if
(swfobject.hasFlashPlayerVersion("10.2.x.x")) to evaluate if 10.2.x.x
is less than or equal too?

Is this possible? Based on your very helpful feed back i wrote the
following. Do you think this would do the same?
Hope i am making sense.... here is the code i tried to re-write below.
-----------------------------------------------------
<html>
<head>
<title>DISPLAY TEXT BASED ON FLASH VERSION</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></
script>

</head>
<body>
<script type="text/javascript">
swfobject.registerObject("myFlashContent",
"10.2.153.1");
if
(swfobject.hasFlashPlayerVersion("10.2.153.1"))
{
document.write("You have FLASH 10.2.153.1 You
Can View This Video"); // This needs to be anything 10.2.x and above
but not sure how to put in the evaluation syntax
}
else if
(swfobject.hasFlashPlayerVersion("10.0.0.0")) // This needs to be
anything less that 10.0 not sure how create evaluation syntax
{
document.write("You Have LESS Than Version 10.2
You Cannot View This Video");
}
else
{
document.write("You Do Not Have Flash Or Correct Version! You
cannot play this video unless you have version 10.2.x or Greater!");
}
</script>
</body>
</html>
---------------------------------------------------------

Your thoughts?
Cheers
RFX

Aran Rhee

unread,
Apr 26, 2012, 10:09:21 AM4/26/12
to swfo...@googlegroups.com
I would suggest you call the getFlashPlayerVersion() method instead and then do a number comparison on the major/minor/elease properties as needed:

<script type="text/javascript">
function outputPlayerversion() {
var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
var output = "You have Flash player " + playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release + " installed";
alert(output);
}
//outputPlayerversion(); // testing before the DOM is available is not fully reliable in non-Internet Explorer browsers
swfobject.addDomLoadEvent(outputPlayerversion);
</script>


Cheers,
Aran
Reply all
Reply to author
Forward
0 new messages