Here\'s my explanation of the question:
From JavaScript, you need to get a reference to the Flash Player object. There are two basic Flash Player versions that ru
Today I got a funny things. I use the common way to embed a flash in my blog.
<object id="flashObject" width="290" height="100" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="movie" value="javascriptcallflash.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
<embed name="flashObject" width="100%" height="100%" wmode="transparent" allowScriptAccess="always" width="290" height="100" type="application/x-shockwave-flash" src="javascriptcallflash.swf"/>
</object>
And I also use the common way to get the flash reference:
<script type="text/javascript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function CallFlashFun() {
var textarea = document.getElementById("jsMsg")
var flashObj = getFlashMovie("flashObject");
flashObj.asFunction(textarea.value);
}
</script>
The problem is that after I publish the post. It doesn't work. So I have try to replace window[movieName]
to window.document[movieName].
Then it works. It's very weird.
What's the different between window[movieName], document[movieName], and window.document[movieName]?
swfobject.js still does this most reliably. So much so that it's been adopted by Adobe as the default embedding script.
The answer is embedded in the question itself. IE uses object
tags and hence SWF is a window
object when embedded with object
tags. Rest of the world uses embed
tags and hence SWF is a property of the window.document
for them.