Solved

Flash auto detection

Posted on 2000-04-12
8
242 Views
Last Modified: 2010-04-03
Hi!

I just started to use Flash and I'ld really like to find out how you can  build a website that autodetects if you have Flash installed - if yes, load Flash animation, if no, possibility to download Flash.
I've tried the built-in option in Flash (with publication settings) but the results weren't quite satisfactory.

Thanx.
0
Comment
Question by:Yogey
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 3

Expert Comment

by:SuperMario
ID: 2710376
Here's the code from hydrarig.com (my favorite reference site for Flash detection, made by me)

Open up your HTML page that has the Flash in it and find the tag that says <HEAD>. If there is no <HEAD> tag, add everything below between a <HEAD> and </HEAD> tag... however you do it, the code below must be between a <HEAD> and </HEAD> tag.

<SCRIPT>
<!--
function validateFlash()
{
      browser = navigator.appName;
      ver = parseInt(navigator.appVersion);
      var hasPlugin;
      if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
      if (navigator.plugins && navigator.plugins["Shockwave Flash"])
            hasPlugin = 1;
      }

      if((browser = "Microsoft Internet Explorer" && ver >= 4) || (hasPlugin == 1))
      {
            self.navigate("FrameFlash.html");
      }
      else
      {
            self.navigate("noflash.html");
      }
}
//-->
</SCRIPT>

Then find your <BODY> tag. It should either just say <BODY> or have a bunch of attributes like <BODY BGCOLOR="blah"> etc.

Add an attribute so that your body tag looks like

<BODY onLoad="setTimeout('validateFlash()', 1000">

Leave any other attributes in there but add the onLoad attribute.

This will cause your page to detect Flash via javascript.

If you need more help lemme know =)

-Dan
0
 

Author Comment

by:Yogey
ID: 2715919
Your code works excellent in Explorer but causes a javascript error in Netscape. I found out it has something to do with the "self.navigate" portion. Do you know a solution for this?
0
 

Author Comment

by:Yogey
ID: 2715948
Your code works excellent in Explorer but causes a javascript error in Netscape. I found out it has something to do with the "self.navigate" portion. Do you know a solution for this?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 3

Expert Comment

by:SuperMario
ID: 2717673
Hmm. I have been told this before also.

Does it give you the same problem if you change it to navigateURL instead of navigate?

Give that a shot =)

-D

0
 
LVL 2

Accepted Solution

by:
burntout earned 50 total points
ID: 2718583
This is what it says to do at macromedia.com (Creaters of Flash)

You should make a new animation that is
18x18 with 2 frames, on the second frame you add a GetURL Action and set it to the "Flash Page" this way the only way they will get redirected to this page is if they have flash. you place this animation on the first page of your site, you also add a meta refresh that will redirect the user in (10 seconds says macromedia but I use 5) this way if the movie does not load and redirect the user in less then 10 seconds they will be redirected to the "Noflash page" Here is a link to the actual macromedia page with this info.
http://macromedia.com/support/flash/ts/documents/scriptfree_detection.htm

I use this and it works great.. if you want to see my site is at...
http://www.323tech.com

good luck!
0
 
LVL 2

Expert Comment

by:coopa
ID: 2725698
Have a look at www.assembly-line.co.uk, I have a page that not only detects the flash version, but then tells the user what version they have.  

It then forwards them on to a flash 4 version if they have flash 4 or a text version if they have any other version of flash or no flash at all.

This works in NSN and IE browsers.

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

 <SCRIPT LANGUAGE="JavaScript">
flashver=0

var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ?
      navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4) {
 flashver=4
}

if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
   && (navigator.userAgent.indexOf("Windows")>=0 && navigator.userAgent.indexOf("3.1")<0)) {
document.write('\<SCRIPT LANGUAGE=VBScript\> \n');
        document.write('on error resume next ');
        document.write('\n');
document.write('If IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")) Then ');
document.write('\n');
document.write('flashver = 3 ');
document.write('\n');
document.write('End If ');
document.write('\n');
document.write('If IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")) Then ');
document.write('\n');
document.write('flashver = 4 ');
document.write('\n');
document.write('End If ');
document.write('\n');
        document.write('\<\/SCRIPT\> ');
        document.write('\n');
}

if (flashver > 2)
{document.write('&lt Flash Version ');
document.write(flashver);
document.write(' detected &gt')};

if (flashver > 3)
{location.href="http://www.flash4version.com"}
else
{location.href="http://www.textversion.com"};

</SCRIPT>
0
 
LVL 2

Expert Comment

by:coopa
ID: 2725709
PS.  This script should sit in the body of your html file, not in the head like most scripts.


<html>
<head>
<title>test</title>
</head>
<body>

Your page here

<script>  My script here  </script>

</body>
</html>
0
 

Author Comment

by:Yogey
ID: 2725765
I've accepted this answer because it seems to be working best.
The other scripts only work partially - just in Explorer and not in Netscape or just on PC's and not on a Mac(!)

Thanx to all of you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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 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.

785 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