Changing the wmode of flash on the fly with javascript

Posted on 2007-08-09
Last Modified: 2013-11-17

I have a drop-down in a page that's coming over flash with default wmode.
After a long search, I read in the Adobe site that the only solution to get other DHTML layers over flash is setting wmode="transparent" . But, setting "wmode" to "transparent" is taking around 20%CPU always.

So, I am trying a way to set wmode on the fly with JavaScript. so, whenever needed , I will change the wmode to transparent and revert it back once done.

I tried this :
document.getElementById("FlashChart").setAttribute("wmode","transparent");  //FlashChart is the name of the flash given in embed tag

But its not working..Any Idea?
Question by:nagki
    LVL 17

    Accepted Solution

    The most likely cause, and I'm just talking of gut-feeling, is that the object won't be able to change the wmode without re-rendering the entire thing. To be honest, I'd be suprised if someone would prove me wrong!

    If it were easy enough to render in wmode and be able to swap it on-the-fly you wouldn't have had the need to investigate this cause the CPU-load would have been negligable.

    Now I would asume that you could re-render the object in wmode by cloning and replacing it, but something with a 20% CPU load would have to be in constant motion and thus cloning it would reset the movie.

    I think the answer in the end will turn out to be: not possible. But I'm keen on finding out if anybody proves me wrong :)

    Expert Comment

    // erratic behavior but close, not tested in other than IE

    function changeWMode(id, wmode)
          var el = document.getElementById(id);
          var child = null;
          var param = el.createElement('param');
 = 'wmode';
          param.value = wmode;
          for (var i=0, end = el.childNodes.length; i < end; i++)
                child = el.childNodes[i];
                if (child.nodeName === 'EMBED')
                      child.wmode = wmode;

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now