Changing arbitrary flash objects wmode to transparent
Asked Answered
N

5

10

I need to change wmode of arbitrary flash objects to transparent from external js file to make sure they don't hide menus without using Jquery or similar libs.

In FF I use getElementsByTagName("embed") and set attribute. It seems to work well.

Specifically I'm having trouble with object set by swfObject library In IE7.

swfObject creates the following code in iE7:

<OBJECT id=mymovie height=400 width=134 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
        <PARAM NAME="_cx" VALUE="3545">
        <PARAM NAME="_cy" VALUE="10583">
        <PARAM NAME="FlashVars" VALUE="">
        <PARAM NAME="Movie" VALUE="imgs/site/tower.swf">
        <PARAM NAME="Src" VALUE="imgs/site/tower.swf">
        <PARAM NAME="WMode" VALUE="Window">
        <PARAM NAME="Play" VALUE="0">
        <PARAM NAME="Loop" VALUE="-1">
        <PARAM NAME="Quality" VALUE="High">
        <PARAM NAME="SAlign" VALUE="">
        <PARAM NAME="Menu" VALUE="-1">
        <PARAM NAME="Base" VALUE="">
        <PARAM NAME="AllowScriptAccess" VALUE="">
        <PARAM NAME="Scale" VALUE="ShowAll">
        <PARAM NAME="DeviceFont" VALUE="0">
        <PARAM NAME="EmbedMovie" VALUE="0">
        <PARAM NAME="BGColor" VALUE="FFFFFF">
        <PARAM NAME="SWRemote" VALUE="">
        <PARAM NAME="MovieData" VALUE="">
        <PARAM NAME="SeamlessTabbing" VALUE="1">
        <PARAM NAME="Profile" VALUE="0">
        <PARAM NAME="ProfileAddress" VALUE="">
        <PARAM NAME="ProfilePort" VALUE="0">
        <PARAM NAME="AllowNetworking" VALUE="all">
        <PARAM NAME="AllowFullScreen" VALUE="false">
</OBJECT>

I tried every possible way to set wmode to transparent and make the flash not hide floating objects without success including but not limited to:

  1. Search for OBJECT and change its PARAM wmode to transparent.
  2. Set attribute of Object (wmode=transparent)
  3. Call the object's SetValue function

None seems to work. Although the wmode seems to change Flash still hides other objects with high z-index. What am I missing here?

Neurovascular answered 10/2, 2009 at 22:17 Comment(1)
Can you give a little more info? Are you just trying to set this once, or to switch it off and on again? Why are you unable to set the wmode when the page is first built?Saith
S
10

I've been successful with this little trick:

$("embed").attr("wmode", "opaque").wrap('<div>');

It effectively redraws the flash object, worked for me.

Salema answered 27/12, 2009 at 14:12 Comment(1)
im not sure if this is the "best" method but it worked for me. thanks.Standley
Q
3

Cirday's solution in general is the right one. Here's a non-jQuery version, that works in IE, FF and Chrome:

var embed = document.getElementsByTagName('embed');
for(var i = 0; i < embed.length; i++){
    embed[i].setAttribute('wmode','opaque');
}
// FF does a "live" array when working directly with elements,
// so "els" changes as we add/remove elements; to avoid problems
// with indexing, copy to a temporary array
var els = document.getElementsByTagName('object');
var obj = [];
for(var i = 0; i < els.length; i++){
   obj[i] = els[i];
}
for(var i = 0; i < obj.length; i++){
    var param = document.createElement('param');
    param.setAttribute('name','wmode');
    param.setAttribute('value','opaque');
    obj[i].appendChild(param);

    var wrapper = document.createElement('div');
    obj[i].parentNode.appendChild(wrapper);

    if(obj[i].outerHTML){
        // IE
        var html = obj[i].outerHTML;
        obj[i].parentNode.removeChild(obj[i]);
        wrapper.innerHTML = html;
    }else{
        // ff/chrome
        obj[i].parentNode.removeChild(obj[i]);
        wrapper.appendChild(obj[i]);
    }
}
Quant answered 22/12, 2011 at 18:12 Comment(0)
J
2

When you are using SWFObject to include the flash, there should be a parameter in the embedSWF method called 'params'. You pass it an object into it like this:

swfobject.embedSwf(blah,blah,blah, { wmode:'transparent'});

more here

Janise answered 10/2, 2009 at 22:24 Comment(2)
Thanks for answering. I have no control over the swfobject part of the code. When my code runs the object is already created.Neurovascular
This is the proper way to do it. You should really see if you can get the person who controls the swfobject code to add the extra parameter.Janise
H
1

It's not true that a flash movie needs to be republished to change the wmode parameter - its a myth:

http://www.communitymx.com/content/article.cfm?cid=E5141

I have the same menu problem, and I need some code to add the wmode parameter to any flash object being called by javascript.

I think the original post pertains to this, but I'm not sure where to start and need more info.

Haun answered 25/7, 2009 at 14:3 Comment(0)
S
0

I'm almost 100% sure that you cannot change the wmode parameter at runtime. I mean, you technically can, but won't have any effect. I'm actually surprised that you got any successful attempts. What Flash player version and browser did you try successfully?

I'm sorry I can't find any official link to prove my point, but I'll leave you this very interesting link about how wmode works (updated to player 10):

What does GPU acceleration mean?

Cheers,

Juan

Schramm answered 11/2, 2009 at 9:43 Comment(1)
I use IE7 and flash player v 9e. There must be some workaround. perhaps restarting the player or reloading the movie??? Any idea would be appreciated. I'm stuck.Neurovascular

© 2022 - 2024 — McMap. All rights reserved.