I’m trying to use JavaScript to call a function in Flash 8.
My code works in Firefox, but not IE6.
I think it has something to do with the fact that my flash object is in a form? In using SWFObject to add flash in my HTML and it’s in a form.
Here’s the html…
<form id="form1" name="form1" runat="server">
.
.
.
<!-- EMBED FLASH OBJECT -->
<div id="flashcontent">
If you are reading this then you don't have Flash.
</div>
<script type="text/javascript">
var so = new SWFObject("AdViewer.swf", "AdViewer", "500", "332", "9", "#ffffff");
so.addParam("quality", "best");
so.addVariable("AdID", "4");
so.write("flashcontent");
</script>
<!-- EMBED FLASH OBJECT -->
.
.
.
</form>
Here’s my javacript
// JAVASCRIPT
// tell Flash to set image
function getAdinFlash( AdID )
{
thisMovie("AdViewer").loadAdNow( AdID );
}
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return document.getElementById(movieName);
} else {
return document[movieName]
}
}
and my Flash, any ideas?
// IN FLASH
//import flash.external.*;
var methodName:String = "loadAdNow";
var instance:Object = this;
var method:Function = loadAd;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
function loadAd(AdID) {
var imgPath:String = "http://localhost/Extanse/InStoreKioskWeb/flashkiosk/imageresponse.aspx?Type=7&AdID="+ AdID;
debugger.text = imgPath;
image_mcl.loadClip( imgPath, imageHolder );
}