UPDATE 25Feb2008 – Adobe has published the recommended workaround for this problem.
This is another major release – I rewrote some of the code with some inspiration from Zelph.com’s onDOMload as suggested by Geoff Stearns, Author of SWFObject. I have now optimized the code to the point where all you need to do is include it in the head of your document and as the page loads, each object will be fixed, so by the time the page is done loading, everything is fixed automatically!
———EDIT 19Jan2007———
I found yet another IE bug related to this topic. After a page is cached by IE and reloaded, the SWF is loaded before it’s embedded, so any callback functions the the SWF tries to setup when it loads (like the JS->Flash ExternalInterface code) will fail with an error “objectID” is undefined. Then when you try to use the callback function you get Object doesn’t support this property or method because the functions didn’t get assigned to the Flash object properly.
To fix this error you need to put this line above your SWFObject code (or above your <object> tag):
Here’s an example document:
http://devel.teratechnologies.net/swfformfix/extinterface-swfformfix2.php
You can download SWFFormFix2 Here:
http://devel.teratechnologies.net/swfformfix/swfformfix2.js
You can see the nicely formatted and highlighted source code here:
http://devel.teratechnologies.net/swfformfix/swfformfix2.js.source
« New ExternalInterface() in Form Example with FLA New Major Tera-WURFL Release – v1.4.4 »

Nice idea but unfortunately it doesn't work in IE 7. "errors on page" every time you click the send buttons. Par for the browser course!
Hmmm…. I just changed the code significantly yesterday to fix an IE caching bug. I'll take a look at it tonight!
Thanks for letting me know!
I figured out what the problem was – it seems that some versions of IE will die unless window[“yourobjectID”] is defined before swfobject loads the SWF. So basically I added the bold line below and it fixed the problem:
<script type="text/javascript">
// <![CDATA[
[strong]window["extinterfaceexample"] = new Object(); // this fixes the ‘“objectid” is undefined problem’[/strong]
var so = new SWFObject("extinterfaceexample.swf", "extinterfaceexample", "350", "375", "7.0.19", "");
so.addParam("quality", "high");
so.write("swfdiv_extinterfaceexample");
// ]]>
</script>
One of our Flash movies is calling out to a JavaScript method in a FrameEnter event. I was getting an error similar to the bug you described with Flash trying to add custom methods before the object is embedded.
To fix this, I did the following:
[code]window["objectid"] = new Object();
window["objectid"].SetReturnValue = function(xml) { };[/code]
When Flash calls a JavaScript function, it injects some JavaScript on the page which expects to be able to call SetReturnValue on the Flash object to get any returned values back into the Flash environment. The code above adds a stub to the temporary object for this method.
I also needed to then modify the SWFFormFixAuto2 function such that it would ignore the SetReturnValue method. The following code gives some context of where my change is:
[code] for(var b in window[id]){
// ExternalInterface() tried to add some functions to the incorrect object
if(b != "SetReturnValue" && typeof(window[id][b])=="function"){
// this function will need to be rebuilt when the page is done loading.
[/code]
In the IF statement, I added the 'b != "SetReturnValue &&' part to ignore the stub method.
Hopefully this comment turns out ok. If not please, feel free to contact me for more details.
Hey,
I'm using this to fix the form problems in IE, but it seems that this has broken the JS to Flash External Interface. I've looked at your sample and it works, but if I download the scripts from your server and put the source into a page on my machine (fixing script links
) It doesn't work. I tried the last comments method, but still no love. Any ideas?
Hello Steve,
Thanks for you your work.
I have a question about noCacheIE() function. Is there a way around that bug? I was really hoping to take advantage of caching as our SWF is pretty large.
BTW. i think i caught the following page as you were updating it: [url=http://devel.teratechnologies.net/swfformfix/extinterface-swfformfix2.php]http://devel.teratechnologies.net/swfformfix/extinterface-swfformfix2.php[/url]
one second noCacheIE() was there and the next it was gone
Thanks.
Mike, the noCacheIE() function is not used by default. I did have some other examples floating around on the Internet that use that function to prevent caching (which also fixes a bug in IE) but you shouldn't need it. When you embed your SWFs you should use code like this:
[code]
var so = new SWFObject("extinterfaceexample.swf", "extinterfaceexample", "350", "375", "7.0.19", "");
[/code]
…and if you want to prevent caching with noCacheIE() you can do this:
[code]
var so = new SWFObject(noCacheIE("extinterfaceexample.swf"), "extinterfaceexample", "350", "375", "7.0.19", "");
[/code]
Let me know if this doesn't solve your problem.
Hello!
I have a big problem and i hope you can help me.
I decided to use SWFObject
<script type="text/javascript">
window["Main"] = new Object();
var so = new SWFObjec("Main.swf", "Main", "400", "200", "9", "#336699");
so.addParam("movie","Main.swf");
so.addParam("quality","high");
so.addParam("allowScriptAccess", "always");
so.write("fdiv");
window["HotsPot"] = new Object();
var to = new SWFObject("HotsPot.swf", "HotsPot", "400", "200", "9", "#336699");
to.addParam("allowScriptAccess", "always");
to.write("hdiv");
function getWrapText()
{
return "TestFromJavaScript";
}
</script>
for example I have next test Flex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="383" height="246">
<mx:Script>
<![CDATA[
import flash.external.ExternalInterface;
public function TestExternal():void
{
if(ExternalInterface.available)
labelTest.text = ExternalInterface.call("getWrapText");
}
]]>
</mx:Script>
<mx:Label x="108" y="69" id="labelTest" text="Test" fontSize="24"/>
<mx:Button x="108" y="155" label="Button" click="TestExternal()"/>
</mx:Application>
The flash is loaded succesfull, but when I click onthe button I have a message "Microsoft JScript runtime error: Object doesn't support this property or method" error in this line
try { Main.SetReturnValue(__flash__toXML(getWrapText()) ); } catch (e) { Main.SetReturnValue("<undefined/>"); }
I read about window["ObjectID"].SetReturnValue=….
but in this case I haven't any results and haven't error.
Could you help me, it 's very important.
Thanks, Olga
Steve I apologize for contacting you directy. I just realized I could just add a comment.
So, I resolved my issue by using Daryl Schwemley's modification so that I could get rid of the js error.
I thank you both,
Andreas
[:)] Tks Steve, i test it in .net V2 (web form) with the fla inside a wizard object and it works!!! It works even betwin posts in the same page! You Did it!!!!
I new that the problem in IE7 were the cach problem, it didnt hapen in IE6, im making use of your noCacheIE() function.
TKS a LOT
the code inside the asp wizard step is (remove the tag 'code'):
<code>
<script type="text/javascript" >
window["Flasher1"] = new Object();
</script>
<script type="text/javascript" src="swfformfix.js"></script>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="x.js"></script>
<!— ****** for the flash object – Remember to allow script source acces on IIS;
—>
<div id="Flasher1" style="WIDTH: 572px; HEIGHT: 115px">
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject(noCacheIE("fileUpload_clientside.swf"), "Flasher1", "572px", "115px", "8", "");
so.addParam("wmode","Transparent");
so.addParam("quality","High");
so.addParam("play","True");
so.addParam("loop","False");
so.addParam("menu","False");
so.addParam("scale","Showall");
so.addVariable("precache", "false");
so.addVariable("uploadPage","Criar_Requisicao.aspx");
so.addVariable("allowScriptAccess","always");
so.addVariable("Cancelar","Cancelar()");
version=0
if (navigator.appVersion.indexOf("MSIE")!=-1){
temp=navigator.appVersion.split("MSIE")
version=parseFloat(temp[1])
}
if (version>=5.5){
so.addParam("wmode", "transparent");
}
so.write("Flasher1");
// ]]>
</script>
</div>
<script type="text/javascript">SWFFormFix("Flasher1");</script>
<script type="text/javascript">SWFFormFixAuto();</script>
</code>
I am having the same problem in IE but with the added complication that I am using AJAX so everything is very dynamic. Works as expected in FireFox. I can call the Flash methods in IE but not the exposed interface for the flash application.
I tried using SWFFormFix to repair the flash instance but the document.write doesn't work well in the Ajax mode. The fix doesn't work in an Ajax application.
Any thoughts on how to do this with an Ajax application.
Please respond with email if you have any suggestions [url=mailto:swillis@videoprotein.com]swillis@videoprotein.com[/url]
Thanks
Scooter
Thanks for sharing this tip, which was recommended to me by a co-worker.
What are your thoughts on supporting webstandards, so instead of using an embed element, then use an "object" element. More info from Ian Hickson: [url=http://ln.hixie.ch/?start=1081798064&count=1]http://ln.hixie.ch/?start=1081798064&count=1[/url]
Seems like I could findt the answer to my question on Geoff Stearns SWFObject blog. SWFObject is discontinued and continues as a web-standards project: SWFFix. More info and an alpha download:
[url=http://code.google.com/p/swffix/]http://code.google.com/p/swffix/[/url]
I have found that swfobject and swfformfix2 run my flash component fine on firefox and all versions of IE apart from IE7 and that this runs fine when first used but I get the javascript error "object doesn't support this property or method" on any subsequent attempts to run it.
Problem: swfobject and Ajax don't work together.
Steve,
Finally I used your example page [url=http://devel.teratechnologies.net/swfformfix/extinterfaceexample.php]http://devel.teratechnologies.net/swfformfix/extinterfaceexample.php[/url] for testing purposes.
First thank you for your great work on swfobject fixes. It helped a lot.
Well. After I conquerd all the obstacles to implement the swf object in ASP.NET pages – I GOT STUCK! with AJAX.
My intention is to put the swf object in AJAX control (collapsiblepanel) and when the user click the closing control let the player stop playing and collaps the panel with the player.
I spend lots of hours to get it done to work with external interface. But vainly.
First I let it work in my computer (just be sure – everything works fine) and then I started to modify it. I wrapped the swfobject in collapsible panel and tested it.
First test: From Flash to HTML/Javascript — PASSED!
Second test: From HTML/Javascript to Flash — FAILED! (and actually I need this direction)
I get this error: "unknown exception" And it gets stuck in eval code, hence it the first line:
obj[functionName] = function(){return eval(this.CallFunction("<invoke name=\"asFunc\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));}
I am using IE6.
Any idea, please?
Thanks.
Steve,
i tried to put a flash movie in a dynamically created div.
but i am getting a err saying object is not defined.
at
<div id="SWFFormFixTESTER" onclick="SWFFormFixCallback(this,'myMovie4');return false;" style="display:none"> </div>
can you please give me a helping hand?
but there is no problem when i embed it in a aspx page.
Hi Steve,
Partial code:
NextNo = NextNo+1;
var newDiv = "Item"+ NextNo;
newDiv = document.createElement('div'); // create dynamically div tag
newDiv.setAttribute('id',newDiv); //give id to it
newDiv.className="DragBox"; // set the style classname
newDiv.overClass="OverDragBox";
newDiv.dragClass="DragDragBox";
var newLabel = "Label"+ NextNo;
newLabel = document.createElement('SPAN');
newLabel.setAttribute('id',newLabel);
newLabel.innerHTML =Desc_Array[k];
var newPanel = "Panel"+ NextNo;
newPanel = document.createElement('div');
newPanel.setAttribute('id',newPanel);
var swfdiv = "swfdiv"+ NextNo;
swfdiv = document.createElement('div');
swfdiv.setAttribute('id',swfdiv);
//finally add the div id to ur form
myContainer.appendChild(newDiv);
document.getElementById(newDiv).appendChild(newLabel);
document.getElementById(newDiv).appendChild(newPanel);
document.getElementById(newPanel).appendChild(swfdiv);
//START – PUT THE SWF IN THE DIV
var id=No_Array[k];
var no=Id_Array[k];
var newMovie = "myMovie"+ NextNo;
window[newMovie] = new Object();
var so = new SWFObject("GaugeQuerySting4/bin/GaugeQuerySting.swf", newMovie,"100", "100", "9", "#ffffff");
so.addVariable("groupId", id);
so.addVariable("groupNo", no);
so.addParam("quality", "high");
so.addParam("wmode","opaque");
so.write(swfdiv);
//SWFFormFix(newMovie);
//END – PUT THE SWF IN THE DIV
}
I get a err on the highlighted line, it shows <div id="SWFFormFixTESTER" onclick="SWFFormFixCallback(this,'myMovie4');return false;" style="display:none"> </div> and gives error as Microsoft JScript runtime error: Object expected.
I don’t know where I err. The same I have in normal divs as
<div class="DragBox" id="Item3" runat="server" overClass="OverDragBox" dragClass="DragDragBox" >
<asp:Label ID="Label3" runat="server" Text="Total Commercial "></asp:Label>
<asp:Panel ID="Panel3" runat="server" >
<div id="swfdiv3" style="background-color: #ffffff" >This is replaced by the Flash movie.</div>
<script type="text/javascript">
var id=80;
var no=85;
var so = new SWFObject('GaugeQuerySting3/bin/GaugeQuerySting.swf', "myMovie3","100", "100", "9", "#ffffff");
so.addVariable("groupId", id);
so.addVariable("groupNo", no);
so.addParam("quality", "high");
so.addParam("wmode","opaque");
so.write("swfdiv3");
//SWFFormFix("myMovie3");
</script>
</asp:Panel>
</div>
</div>
There is no problem here.
Problem comes only when dynamically creating the control.
Kindly help us to solve the problem
This part of your code is not going to work correctly from what I can tell:
var swfdiv = "swfdiv"+ NextNo;
swfdiv = document.createElement('div');
swfdiv.setAttribute('id',swfdiv);
You probably want this:
var swfdiv = document.createElement('div');
swfdiv.setAttribute('id', "swfdiv"+ NextNo);
Otherwise you would be setting the ID (a string) to and Object (the new div) which would result in evaluating the div as a string (swfdiv.toString()) – this probably ends up as null which could force the DIV to have a null ID or make its own ID.
Also, you don’t need SWFFormFix unless you are putting your SWF inside a FORM element and you need to register a callback function in Flash/Flex with the ExternalInterface class. Otherwise, just use SWFObject or AC_RunActiveContent.js.
By default, SWFFormFix is in Auto mode, where it tries to find and fix all the SWFs on the page, but this might be the problem with your code – try commenting out the swfformfix.js in the HEAD or going into the file and turning off Auto mode.
Thanks,
Steve Kamerman
sorry Steve,
i found that err, on the other day and changed it to
var swfdivid = "swfdiv"+ NextNo;
swfdiv = document.createElement('div');
swfdiv.setAttribute('id',swfdivid);
var newMovie = "myMovie"+ NextNo;
newPanel.appendChild(swfdiv);
var id=No_Array[k];
var no=Id_Array[k];
var newMovie = "myMovie"+ NextNo;
var so = new SWFObject("GaugeQuerySting4/bin/GaugeQuerySting.swf", "myMovie4","100", "100", "9", "#ffffff");
so.addVariable("groupId", id);
so.addVariable("groupNo", no);
so.addParam("quality", "high");
so.addParam("wmode","opaque");
so.write(swfdivid);
SWFFormFix(newMovie);
this is the code i use now.
but the problem is still there.[:(]
/*Also, you don’t need SWFFormFix unless you are putting your SWF inside a FORM element and you need to register a callback function in Flash/Flex with the ExternalInterface class. Otherwise, just use SWFObject or AC_RunActiveContent.js. */
i need to use SWFObject as i need to call a function from flex.
i have a question also. will this not work when the control is created dynamically.
hi steve,
i tried to create the controls dynamically n place the swf inside it. now there is no problem in loading the div. but i get a error when i am calling the call back function.
i get 'unknown exception' err at
function __flash__addCallback(instance, name) {
instance[name] = function () {
return eval(instance.CallFunction("<invoke name=\""+name+"\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));
}
}
i dont have any clues of why this happens!!! kindly help [:(]
You still don't need SWFFormFix – it is only for SWFs that are inside FORMS. You can just call SWFObject to add the swf to your page like this:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function addSWF(){
var so = new SWFObject("flashForm.swf", "flashform", "550", "400", "9.0.28", "");
so.addParam("quality", "high");
so.write("swfdiv_flashform");
}
</script>
<script type="text/javascript" src="/swfobject.js"></script>
</head>
<body>
<div id="swfdiv_flashform" style="width:550px;height:400px;">
SWF Goes Here
</div>
<input type="button" name="button" id="button" value="Add SWF" onclick="addSWF();" />
</body>
</html>
[/code]
Here's a working example: [url=http://devel.teratechnologies.net/test/addswfdynamically.html]http://devel.teratechnologies.net/test/addswfdynamically.html[/url]
but i need to set the height and width dynamically. so i have a callBack function which returns the height and width.
i could get the swf with out problem but i couldnt call the callBack
var myid = "myMovie"+i;
var HW = document.getElementById(myid).callMeBack();
var HW_array = HW.split(",");
but the callback function couldnt be called for dynamically created ones.
hi steve,
i created a div dynamically and put my swf into it. now how to call a flex function from that?
i tried like
window.onload = function()
{
myMovie1.myFlexFunction();
}
in flex i have written
private function init():void
{
ExternalInterface.addCallback("myFlexFunction",mydata);
}
public function mydata():void
{
var height:Number = 150;
var width:Number = 200;
var con:String = height +","+ width;
var jscommand:String = "parent.test('"+con+"');";
var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(url, "_self");
}
but i get err saying
Microsoft JScript runtime error: Object doesn't support this property or method
kindly help i am stuck with this for many days [:(]
hi steve,
i have a doubt.
this is the senario.
i have say, 5 movies. in a for loop i call a flex func. the flex func. in turn calls a JS called test.
i thought the test function will be called for all movies but it is called for only one movie.
what is the reason. and what shd i do for calling test by all the movie?
Hi,
I've a problem using swffixform with IE ! ! !
Actualy, if I put in my code : [code]SWFFormFix("FlashDynamicPageBuilder");[/code]
When this code is executed, IE seems to empty (the adress don't change, but the page became totaly white, empty) my page and make a verification. This issue is on IE 6 and IE 7. I don't know what to do. I want to use swffixform for IE because I want to use exteralInterface and let javascript call flash method. But if the solution, swffixform, create another issue, I think I'll lose my mind
Thank you
Thank you very much for all the hard work you have put into this application. I believe (and am hoping and praying) that everything is finally working. I am so glad I decided to read the comments and learned about the noCache function you wrote as that was driving me crazy.
You should put a PayPal link up for donations as I think you just saved my job.
Very big thanks. I long worked above this problem, you fix has solved all:)) Once again thanks [:)]
The link to the Javascript file seems to be broken:
[url=http://devel.teratechnologies.net/swfformfix/swfformfix2_2-0-0.js]http://devel.teratechnologies.net/swfformfix/swfformfix2_2-0-0.js[/url]
on this page:
[url=http://devel.teratechnologies.net/swfformfix/extinterface-swfformfix2.php]http://devel.teratechnologies.net/swfformfix/extinterface-swfformfix2.php[/url]
I viewed source and downloaded the script, but it seems to be v2.0.1 and I'm not sure if that's the latest version or not.
Also, I'd like to add my thanks for posting this! It's the first one I've found that actually seems to work in IE7 and Firefox!
Doesn't work if the form doesn't have an id or name, which by default it doesn't when using .Net applications.