FlashObject 1.2

I’m pleased to announce version 1.2 of my FlashObject script. The big new addition is minor version detection and revision detection, so now you can detect versions like "6.0.65" if you like. I also got some advice from Toby Boudreaux, who provided tons of help in getting the code all fancied up and name spaced, so it shouldn’t collide with any other scripts on your websites now. We also went through and leaned out some features that weren’t being used much. Namely the fo.altTxt var and the extra line that included the bypass detection link. You can still bypass the detection just as you have been, but the script will no longer automatically write the alternate content at all (even if you manually override it like you could in v.1.1). If you have no idea what that last sentance means, just ignore it, as you probably weren’t using the feature anyway.

I’ve also given FlashObject a permanent home at http://blog.deconcept.com/flashobject/.

Here’s the full list of what has changed:

  • fo.write() now requires an element ID. In previous versions you could call write() with no parameters and the FlashObject script would write the Flash movie to the page wherever the script was placed on the page. This is no longer the case and now you must specify an element ID.
  • fo.altTxt no longer exists. You must now place all your alternate content or upgrade message in the div where your Flash content will be written.
  • fo.redirect no longer exists. When using FlashObject to redirect users to a separate upgrade page, you now specify the redirect url like this: fo.setAttribute('redirectUrl', 'http://www.example.com');

I highly recommend upgrading to this version. While I was adding the minor version detection, I found a bug that will cause Netscape plugin based browsers to fail the Flash detection once the major version gets up to two digits. That means it will work fine up to Flash 9, but then return 0 if the user has Flash player 10 (this is all assuming Macromedia keeps incrementing the version numbers, and that Adobe doesn’t change everything around when they take over).

So that’s it. This will probably be the last version update to FlashObject, since there isn’t much else I could add that would be useful to everyone. So go tell your friends about it – there’s really no reason you shouldn’t be using this to embed your Flash movies.

UPDATE: Dave Benjamin pointed out a flaw in the new detection checking function, and that has been fixed. I also fixed a very small issue with the version check that would cause it to fail if you had version 9.1.0, and the page required 8.2.0 (for example), so make sure you get the latest version.

UPDATE (07-27-2005): Matthew Richmond set me up with a better looking test file, that also shows the full page version much better, so the download / example pages have been updated.

UPDATE (08-01-2005): Just fixed a bug in the detection function that would throw an error when no Flash player was installed, thus casing the redirect to fail if you were trying to redirect users to an upgrade page. Thanks to Carl Wurtz for pointing that out. I also took the chance to update the ActiveX plugin detection code. No more VBscript in there (not even an execscript() call). New version number is 1.2.2 – make sure you have the latest version!

35 thoughts on “FlashObject 1.2

  1. Just a quick comment, the test example is outputing “You have Flash player 8.0.NaN installed.” for me. I assume MM is using some alphabetical characters in the beta version of the player. However it is an indication that they are willing to use letters in the version number, so it may be necissary to accomidate for those.

  2. To my earlier comment, I guess the real version is 8.0.0.434, so no letters in there. Still an issue as far as what popped out of your test example.

  3. Rasmus,

    I don’t like that one because it doesn’t load the Flash content until the page is fully loaded. I’ve used FlashObject on a few sites that have large content filled pages, and if it waited until everything was loaded before showing and loading the Flash content, it would look rather odd with things appearing slowly.

    Ian,

    I set it up to ignore the beta versions of the player. If you have one of the betas, FlashObject would report that you have 8.0.0 installed. Also I just made a small change so the script will return 8.0.0 instead of 8.0.NaN. So download the zip again if you already have it.

  4. Is there any way to call a function in Flash from Javascript using FlashObject? I know that you can do it with the (new) MM Javascript Integration Kit,but I didn’t see documentation supporting this functionality.

  5. Scott –
    I’ve been sketching a nice little version of FO based on FO1.2 that uses the MM JS kit and lends itself to a Ruby on Rails helper. I’ll have Geoff post a link when I have something done.

  6. Cool Toby, and if you don’t want to wait, it would be really simple to use FlashObject together with the MM JS integration kit – just replace any code that embeds a Flash movie with the FlashObject code.

  7. Hi,

    When using the scrollwheel , the fullpage.html sample is moving up and down. This occurs only with Mozilla firefox 1.04.
    Does anyone experiment the same ?

  8. It’s a byproduct of the CSS used to stretch the page to 100%. Normally there would be a scrollbar showing, but I have the scrollbar hidden. If you want to fix that, you could possibly set the height of the html and Flash container element to 99% instead of 100%.

  9. Just downloaded FO and am getting this error when I open fullpage.html in NN 7.1:
    Error: com.deconcept.FlashObjectUtil.getPlayerVersion() has no properties, with no page redirect
    Any idea why?
    thanks

  10. just found this script…excellant work.

    I could not find any refs to using the alternate content to print in place of the swf…my idea is to use an image as alt content and have that print in place of the swf when the viewer chooses “print page”..any suggestions or if someone can pont me at a referance, thanks

    Pz

  11. You could use a print stylesheet for that. Place the image on the page and hide it with your ‘screen’ stylesheet, then in the ‘print’ stylesheet, hide the Flash content and show the image.

  12. hymm, you lost me there. the alt content is in the page and displays to anyone with javascript turned off or no flash, so if I hide the img I kind of defeat the purpose of the script. I tried #flashcontent object {display:none} in the print.css to no avail, I don’t think it is being recognized as an object

    maybe I am missing something obvious?

  13. You would have to put the alternate content outside of the #flashcontent div. Otherwise the script will replace the content, and when you try to print it, it will be gone.

    Then you place the #flashcontent { display: none } in your print stylesheet so the Flash content won’t print.

  14. thanks,

    what I have done is nested the #flashcontent inside a div holding the alt content (#altcontent) and applied the following styles..

    #altcontent {float:right; width:220px; height:220px; margin:10px; position:relative;}
    #flashcontent {position:absolute; top:0; left:0; z-index:100; margin:0; padding:0;}
    @media print {
    #flashcontent {display:none;}
    }

    works at first glance. it will probably fall apart in IE/Win like most of my brainstorms but at least i am off in the right direction…thanx

    Pz

  15. Hi!

    I’m currently playing a bit with the Flash Javascript Kit Integration.
    I was wondering how I could make worked together the FlashTag and FlashObject classes.
    Any advices ?

    Thanks.

  16. Hi Geoff! This thing works great…solved a couple nagging problems for me. I’m working on a page with multiple (8) embedded instances of a flash movie (they’re fancy flash hotspots over the top of a “casement window” image pointing out the different features of the window). Anyways, everything’s working pretty solid, except for Safari. Safari doesn’t seem to like the use of FlashVars as a variable WHEN you’re instantiating multiple flash objects that all are using the same .swf file. I finally found this link documenting the problem, but no solutions.

    http://www.impossibilities.com/blog/entry_blog-106.php

    I noticed that I can get up to 3 or 4 flash objects to “embed”? properly, but once I add any more, things get pretty dicey, and anything over 4 starts displaying some serious random functionality upon each page refresh. I even went to the extreme of naming each *.swf with a name1.swf, name2.swf, and that didn’t work either. So now I’m wondering if its not the same .swf name problem, but rather that Safari just can’t handle the heavy duty parsing that’s going on between the html, jscript, etc.

    Your embed object actually HELPED this (i could only get two to work simultaneously when using Macromedia’s embed recommendations), but still not good enough, really.

    Any thoughts, suggestions?

    http://www.impossibilities.com/blog/entry_blog-106.php

  17. Michael,

    I believe the FlashTag js file uses very similar syntax to FlashObject, so it would probably very simple to modify the integration kit code to use FlashObject instead. It would just be a matter of finding all the FlashTag references and replacing them with FlashObject code.

  18. Nathan,

    I went to the sample page you posted with Safari (2.0 on OS X 10.4.2), and then to his homepage with the multiple ‘speak’ buttons, and clicked most of them with no problems. Each one played the correct audio.

    I’m using Flash player 8 public beta player – so maybe this was an issue in earlier Flash players? What player version do you have installed, and what version of Safari are you using?

  19. (About replacing the FlashTag references with FlashObject code)

    I will dig in this direction…,
    Thanks for the clue!

  20. I must say this is really, really top quality work and ethos. Making and posting this code is one of the most worthwhile things I think anyone could have done – nice one!

    One comment: pages are validated as strict xml, etc. in order to ensure that people writing programmes are able to render the document properly. If I make an xhtml1.1 page that validates by including a script file that then writes invalid html code (eg: codebase=”…”) to the document held in the browser’s memory, the document is invalid and may be parsed / rendered incorrectly. While this method is A* and will fool your client into thinking the page is ‘valid therfore futureproof’, don’t fool yourself. You may not see invalid source when you hit Ctrl+U in FireFox, but FireFox does when you spit it out and just happens to render it properly.

  21. Hi!

    I’m currently playing a bit with the Flash Javascript Kit Integration.
    I was wondering how I could make worked together the FlashTag and FlashObject classes.
    Any advices ?

    Thanks.

  22. You should be able to simply replace the FlashTag calls with FlashObject calls… but you might want to disable the plugin detection on some of the calls – when you send a value to the Flash movie, you don’t want to check for the Flash player again because it might be a little slower. It probably wouldn’t be noticably slower to most people, but there could be small delays in passing values back and forth.

    You can disable the detection by using this line:

    ...
    fo.skipDetect = true;
    ...

  23. Geoff, thanks SO MUCH for this. Amazing. I, like Nathan previously, noticed that Safari just isnt happy. I *just* downloaded this, so unfortunately I hadn’t even found out why. But since he hasnt answered the version question, I’m using version 7.x plugin. I think it would suck to have to download a *new* Flash plugin to view material that’s built using FlashMX2004 (7). And i’m using Tiger. I have no idea if that screws with anything.

    Let me know if you want me to dig on something….

  24. Billy,

    Well Nathan was only having problems with Flashvars and only with using many many flash movies on a single page. Can you be more specific about what is wrong? FlashObject has been tested in all versions of Safari, and there are no issues that I know of.

  25. I’ve been pulling my hair out the last couple of days testing flash player 6.0.23.0 and 6.0.29.0 with the flashObject script. Works fine in Firefox and Opera, but IE refuses to work. I’ve found that it’s only these two players (they’re old I know) that don’t work and it appears to be something to do with the “new ActiveXObject(“ShockwaveFlash.ShockwaveFlash”)” code in the javascript file. The older version of flashObject (the one that used vbscript to detect the version in IE) appears to detect the flash player version correctly. Can anyone out there please shed some light on this for me, either by testing these players with there flashObject scripts or enlightening me as to why those two players don’t appear to like the javascript IE player detection scripting…?

    Thanks in advance

    Jason

  26. Hi – I wanted to redirect if the Flash version is valid – the opposite of the current functionality. I changed the code a little and added a ‘redirectIfValid’ variable (needed changes to constructor and ‘write’ method). You can download the changed version at http://www.hub124.net/test/flashobject.js – could something like this be added to the main build?

    – Nils.

  27. and here is an example:
    [code]
    var fo = new FlashObject(“flash/home.swf”, “home”, “630”, “267”, “6”, “#ffffff”);
    fo.setAttribute(‘redirectUrl’, ‘index_flash.html’);
    fo.setAttribute(‘redirectIfValid’, true);
    fo.write(“”);
    [/code]

  28. Is it possible to give the user the option to download Flash Player if it’s not installed? From what I can see, if Flash is not installed, the alternate content (e.g. an image in the flashcontent div) is displayed. But if Flash is not installed, I want to do something like display two buttons (Install, Don’t Install). The Install button would do the same thing that a browser (like IE or Firefox) does — that is, it installs Flash without going to the Macromedia download page. The Don’t Install button would simply show the alternate content.

  29. Sure. If you wanted to invoke the browser’s install dialog, you could put a link to bypass the detection. This would attempt to show the Flash content and the browser should try to find the plugin.

    The other button that shows the alternate content would be a little trickier and would require a bit more Javascript.

    You might consider showing your alternate content and then adding a small message saying ‘for the full experience please intall the macromedia (adobe?) flash player’ and the link could just be the bypass detection link (see the example page for how to use the bypass detection link)

  30. I’m having problems getting more than one flash object to display on my page.
    Could anyone give me a code example or point me in the right direction?
    I’ve read in previous posts something about changing the div id tag but after some trial/error I get one swf to load while only the alt content displays for the second. I’m still not sure about how to do this correctly.
    Any help will be Greatly appreciated…
    Thank you all, spl.database

  31. Hi, I’ve been trying out FlashObject and it works great, except for on IE6 where it can’t find the Flash file!
    The page just sticks with (1 item remaining) and lays there. Take a look at http://www.alanmoore.info/ and there should be a flash movie on the right below the menu.
    The only thing that’s different really is that the div element is positioned, not floated.
    What’s weird is it worked on IE the other day… and it still works under Safari. Any clues?

Comments are closed.