Search code examples
swfobject

Conflict between swfobject and swffit


  • swfobject.js - among other things - detects whether the browser has the flash plugin, and if it does not, displays an error message (e.g. click here to get the flash plugin).
  • swffit.js allows you to set minimum and maximum size for your swfs, so they shrink for small screens and enlarge for big screens (and, miraculously, it centers the swf X and Y).

The swffit download examples run swfobject.js first, then swffit.js. This causes the following...

  • In FF and Chrome with flash plugin enabled, swffit does its job
  • In FF and Chrome with flash plugin disabled, there is no swf, but also no error message, just a blank screen - somehow swffit overrides swfobject's very useful function.

Reversing the order, i,e. swffit.js first, then swfobject.js...

  • In FF and Chrome, with flash plugin enabled or disabled, I get no swf but there is the error message.

In summary, I need the swffit's resizability, but also swfobject's error message, but it looks like you can't have both together with these two scripts. Any ideas anyone?


Solution

  • On further investigation, I found it was a placement problem, not a script conflict. If you disable your flash plugin and try the Example Pages (bottom of page) here:

    The Basic example (1) shows the swfobject error message, but the Example Page With Maximum Size - Centered (4) does not.

    Playing with css on a local file, it turned out the message was there (in 4) but off the screen top left. If you look at (3) Example Page With Maximum Size - Centered Horizontally you can see the problem.

    The fix was - in the case of swffit.fit("my_flash",550,289,800,436):

    <div id="my_flash" style="position:relative;">
    <div style="width:550px;height:289px;text-align:center;margin:0 auto;">
    <div style="margin:0 auto;width:120px;text-align:center;margin-top:100px">
    error message here
    </div>
    </div>
    </div>
    

    That centers the error message at max width (800px) and minwidth (550px).