hiimnalaa / swfobject

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

External interface to div-wrapped swf fails in IE+swfobject 2.2 - Works with 2.1 #412

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Embed a flash using embedSWF in a function called on body onload

2. Wrap it in a DIV using code like this :
var wrapper = document.createElement('div');
wrapper.appendChild(document.getElementById("FlashContainer"));
document.body.appendChild(wrapper);

3. Provide a JS function with a return value to call from External Interface :
function jsfunction(){
alert("in js function");
return "123";
}

4. Make a simple Flex that calls the function :
private function creationCompleteHandler():void {
    if( ExternalInterface.available ) {
    trace( ExternalInterface.call('jsfunction') );
    }
}

What is the expected output? What do you see instead?

Flash tracer shows the return value 123 in Firefox and Chrome but "null" in
IE8, using swfobject 2.2 (even though the alert shows that the function is
entered). Works on IE8 using swfobject 2.1 instead of 2.2 .

What version of the product are you using? On what operating system?

swfobject 2.2..windows vista

Original issue reported on code.google.com by benjamin...@gmail.com on 3 Dec 2009 at 3:03

GoogleCodeExporter commented 9 years ago
Can you please provide a link to a complete test page, so it can be reviewed?

Original comment by aran.rhee@gmail.com on 3 Dec 2009 at 11:08

GoogleCodeExporter commented 9 years ago
absolutely

swfobject 2.1 :

http://vtz10.virtuoz.com/swfobject/index_2_1.htm

swfobject 2.2 :

http://vtz10.virtuoz.com/swfobject/index_2_2.htm

Original comment by benjamin...@gmail.com on 4 Dec 2009 at 10:47

GoogleCodeExporter commented 9 years ago
When it comes to handle cross browsing issues and AS-JS comunications using 
SWFobject i usually give up...

Original comment by iriarte....@gmail.com on 2 Jul 2010 at 3:53

GoogleCodeExporter commented 9 years ago
Hi Benjamin

Your example is confusing: you're trying to wrap the <object> (Flash SWF) in a 
<div> *after* embedding. This could possibly lead to ExternalInterface issues 
because you're manipulating the DOM element containing the SWF after it has 
embedded. 

Your code: 

function embed() {
    var flashvars = {};
    var params = { allowScriptAccess:"always" };
    var attributes = {};
    swfobject.embedSWF("Test.swf", "FlashContainer", "300", "300", "10", "expressInstall.swf", flashvars, params, attributes);
    var wrapper = document.createElement('div');
    wrapper.appendChild(document.getElementById("FlashContainer"));
    document.body.appendChild(wrapper);
}

I suggest you add your wrapper *before* you embed the SWF, like so:

function embed() {
    var wrapper = document.createElement('div');
    wrapper.appendChild(document.getElementById("FlashContainer"));
    document.body.appendChild(wrapper);
    var flashvars = {};
    var params = { allowScriptAccess:"always" };
    var attributes = {};
    swfobject.embedSWF("Test.swf", "FlashContainer", "300", "300", "10", "expressInstall.swf", flashvars, params, attributes);
}

I'm going to chalk this up as an implementation issue, not a SWFObject bug. 

If you would like to pursue this further, feel free to post a follow-up with 
additional information.

Thanks

Original comment by platelu...@gmail.com on 17 May 2011 at 11:51