How to Position Flash beneath Other Content

Flash Web Development

By default, Active Content is written directly to the screen, which means it appears on top of other HTML content, regardless of its z-index stacking order, as defined by CSS.  This includes Flash, QuickTime, Windows Media, Java applets, and basically any other file that requires a plug-in in order to be displayed in a browser. 

One of the most popular questions in regard to this issue is some variation on the following:  “Flash is showing through my drop-down navigation!  How can I keep this from happening?”  The answer is provided on Adobe’s website in TechNote #15523.  This TechNote has been available since December 2002, when it was written under the auspices of Macromedia.  Unfortunately, it has been factually incorrect from the very beginning — not fatally flawed, but certainly misleading.

Update!  Adobe revised this TechNote!  Not sure when, exactly, but obviously some time between the original date of this blog entry (07/18/2006) and today (11/29/2006). 

The scoop

The key to getting a browser to recognize the stacking order of Active Content is something called WMODE (windowless mode).  Fair warning, WMODE is one of those phenomena some developers see as “evil,” like ActionScript’s _root and _global — an assessment I personally find unjust.  If you happen to swing that way, so be it.  ;)   But bear in mind, the buck doesn’t stop with Adobe on this particular feature:  WMODE was neither the invention of Adobe nor Macromedia.  In a case of “if you build it, they will come,” browser manufacturers provided the feature and Macromedia responded to it with Flash Player 6.  Yes, WMODE causes a performance hit, and yes, WMODE has been documented as buggy in the community.  But given the alternatives (none), and depending on the audience, it is a valid tool in the arsenal, when handled with due diligence.

So, what is this funny term?  WMODE is a browser feature that allows Active Content to be written to the browser’s composition buffer, rather than directly to the screen.  It is this trait that makes stacking order possible in context of Active Content.  It is also this trait that forces the browser to “think harder” when rendering its pixels, which causes the performance hit.  See the Wmode Woes entry of Justin Everett-Church’s Flash blog for additional information on accessibility issues and matters of inconsistent performance.

If you’re still interested, WMODE is easy to implement.

An answer, short and sweet

The <object> and/or <embed> HTML elements that reference your Flash content accept a number of optional parameters.  For the <object> element, these parameters are supplied via nested <param> elements.  Simply add the following new <param>:

<param name="wmode" value="opaque">

The <embed> parameters are supplied via attributes.  For the <embed> element, add the following new attribute:

wmode="opaque"

That’s it.  Your Flash content is now stackable via z-index; for example, you may wrap your <object>/<embed> pair in a <div> and set the <div>’s z-index as you please.

<div style="position: absolute; z-index=1;">
 <object attributes >
  <embed attributes />
 </object>
</div>

If you’re using Dreamweaver, just press the Parameters button in the Insert > Media > Flash dialog or in the Property inspector when selecting existing Flash content.  Type “wmode” (without quotes) in the name/parameter column and “opaque” (without quotes) in the value column.  That will handle the above HTML for you, even with the new JavaScript embedding available since the 8.0.2 update.

Know your options

The Adobe TechNote I mentioned incorrectly implies, as of this writing*, that WMODE must be set to transparent to make Flash content stackable.  There are actually three WMODE possibilities:  opaque, transparent, and window.  Of these, both opaque and transparent allow the z-index stacking order — and opaque is purportedly the less buggy of the two.  The transparent option is only necessary when a transparent background is desired in addition to stacking order.  The window option is the default, and leaving it off is the same as specifying wmode="window".

* Update!  Adobe revised this TechNote!  Not sure when, exactly, but obviously some time between the original date of this blog entry (07/18/2006) and today (11/29/2006).

For additional detail, check out Stephanie Sullivan’s “Flash, DHTML Menus and Accessibility” (free content) article on Community MX.

And here’s the TechNote, for sake of completeness.  Just remember that transparent is not compulsory.

http://www.adobe.com/go/tn_15523

20 Responses to “How to Position Flash beneath Other Content”

  1. Andy Says:

    Good article,

    any ideas on how to do transparent video ? FLV, ive been looking at:

    [http://www.pjenkins.co.uk/ link]

  2. David Stiller Says:

    Andy,

    That looks like a decent tutorial. Seems like that ought to give you what you need.

  3. mike d Says:

    The related problem seems harder to solve. That the mouseover hand doesn’t appear on html links that are placed above a flash movie. Any ideas?

    mike d

  4. David Stiller Says:

    mike d,

    What you’re describing is simply one of the “dangerous” steps on the WMODE / Flash-layering slippery slope. Different browsers will handle things in different ways, and some people avoid WMODE for the very reason you’ve stated.

  5. Will Says:

    Very useful thanks! Wordpress or whatever generates this page has the footer at the bottom a pixel or so out of line (on firefox anyway). :S

  6. David Stiller Says:

    Will,

    Hey, glad to hear it. :) Yeah, I’ve noticed that errant pixel, but ehh … there’s something that appeals to me about the default skin of WordPress. It’s relatively clean and uncluttered, and until I get around to working out a layout of my own for this blog (some day!), the frugal nature of the visuals keeps my writing in line. ;)

  7. wmode 三選一 « 就是愛程式 Says:

    […] How to Position Flash beneath Other Content […]

  8. Alexandre Vieira Says:

    Excelent article!!!

    It helped me a lot. I had a web page with a div that should appear in front of a flash object, but it was appearing behind. In IE it worked fine, but not in Firefox. So I fixed the problem using the tag and wmode=”opaque” in embed tag.

    Thank you

  9. David Stiller Says:

    Alexandre,

    You’re welcome! :)

  10. Sean Says:

    Thanks a lot!

    This was great help. I had no idea it was going to be this easy!

  11. David Stiller Says:

    Sean,

    Glad to hear that!

  12. meghan Says:

    For some reason this is still not working for me in IE (its fine in FF, with a couple of minor glitches)… i did everything you instructed above and then i set the div around my dropdown menu to position:absolute and z-index: 100;

    any ideas?

  13. David Stiller Says:

    meghan,

    I would probably have to see your HTML page in action to see what’s going on. Could you post a URL?

  14. Scott H. Says:

    David - thank you for pointing me to this solution. Where I was missing was in the JavaScript Flash Player Detection and Embedding - I needed to add the name/value pair for wmode. Worked like a charm after that! Here is the kb from Adobe:

    http://www.adobe.com/devnet/activecontent/articles/devletter.html#multipleoccurrences

  15. David Stiller Says:

    Scott,

    That’ll do it! :) Good on ya!

  16. Jin Says:

    Thanks a lot. It really works. It really solved my problem. Great job.

    I used it in this website http://sure.com.ph

  17. David Stiller Says:

    Jin,

    Glad that worked for you!

  18. Piyal Kundu Says:

    Thank you very much for your tips. This is very much needed for my project.

  19. Paul O'Neill Says:

    Hello David,
    Thanks you for your tip unfortunately it’s not really working for me. You can see from my link. The logo (contained in a div) is not appearing above the flash banner. Fine FF not in IE6 :)

    I’ve put in the parameter for opaque and transparent.

    any ideas?

  20. Gargamel Says:

    I also can’t get it to work on IE.
    You can check the link http://perpetuumjazzile.si

    The big flash push on the left side (for the concert) has a link over it

    - works in FF2, FF3, GoogleChrome and Opera,
    - *doesn’t* work in IE6 and IE7!

    I’ve tried:
    - wmode: transparent
    - wmode: opaque
    - z-indexing the OBJECT
    - wrapping flash with a div and z-indexing it
    - moving arround the DOM (link before flash and vice versa) - it was a long shot, but worth trying

Leave a Reply