ehtasham89 / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

Overcoming resetting of div/span style by a simple logic #598

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
----------------------------------
Using the embedSWF method.

What is the expected output? What do you see instead?
----------------------------------
Resets all the styles associated with that div. It would be great if it could 
create a temporary object to hold the classname and then reassociate it with 
the span/div once the movie gets loaded.

What version of the product are you using? On what operating system?
----------------------------------
swfobject v.2.2 on Mac OS 10.6.8

Please provide any additional information below.
----------------------------------
I took some(!)time to reformat the JS code (with newlines/spaces/tabs) and 
figured out what's going on so resetting the style (class, in my issue) seems 
to be an expected behavior. It removes the style and replaces it with the 
single property - display:block. I kind of 'patched' it by creating a function 
like the following and I though I should share it with you since it is an easy 
solution and I think it might be added to the next release as default, perhaps 
by an additional method or parameter.

var flashDIVS = {};

function 
embedFlash(file,divID,width,height,version,xiURL,flashVars,params,attrs) {
    var curStyle = document.getElementById(divID).className;
    flashDIVS.divID = curStyle;
    swfobject.embedSWF(file,divID,width,height,version,xiURL,flashVars,params,attrs,onFlashLoad);
}
function onFlashLoad(evt) {
    var divElement = evt.ref;
    var divID = evt.id;
    var cssClass = flashDIVS.divID;
    delete flashDIVS.divID;
    divElement.className = cssClass;
    // divElement.style.display = "block"; // if needed
}

embedFlash("mov.swf", "movDivID", "5000px", 
"200px","10",false,false,false,false);

Original issue reported on code.google.com by pangar....@gmail.com on 28 Oct 2011 at 3:07

GoogleCodeExporter commented 9 years ago
swfobject.embedSWF doesn't delete your class attribute, it deletes the entire 
element and replaces it with an <object>.

You can transfer the original element's class to the new <object> using the 
attributes option:

var flashvars = {};
var params = {};
var attributes = { styleclass: document.getElementById(divID).className };
var callback = function (){ };

swfobject.embedSWF("mov.swf", "movDivID", "500", "200", "10", false, flashvars, 
params, attributes, callback);

Why "styleclass"? Read the docs:
http://code.google.com/p/swfobject/wiki/documentation#How_can_you_configure_your
_Flash_content?

Also, you shouldn't put "px" in your dimensions, you should to enter numbers 
only, such as '500' instead of '500px'

Original comment by platelu...@gmail.com on 28 Oct 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Thank you for the input. I don't know how I missed that in documentation, I 
thought I'd read it all.
Anyway thanks again. This is a life saver :)

Cheers.

Original comment by pangar....@gmail.com on 1 Nov 2011 at 12:22