PDA

View Full Version : JavaScript to Flash Communication Requires raw HTML <embed> tag; Way Around?


shane.carr
08-05-2007, 08:39 AM
Hello,

I am working on a JavaScript to Flash (and Flash to JS) program in XHTML. Because of Internet Explorer's Compatibility Problems, I have to use Dreamweaver's AC_FL_RunContent() code. However, this seems to mess up the communication.

Here's the embedding code (It doesn't work in this configuration, but when the JS and the <noscript> tags are removed, it works beautifully)

<script type="text/javascript">
<!--
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','50','height ','10','src','mymoviepath','quality','high','plugi nspage','http://www.macromedia.com/go/getflashplayer','movie','mymoviepath','allowScript Access','sameDomain','id','flashObject' ); //end AC code
// -->
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="50" height="10" id="flashObject">
<param name="movie" value="mymoviepath.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="mymoviepath.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="50" height="10" name="flashObject" allowScriptAccess="sameDomain"></embed>
</object>
</noscript>

Here's the JavaScript that I need to work along with it:

var flash;
function addFlashIntegration(){
if(navigator.appName.indexOf("Microsoft") != -1){
flash = window.flashObject;
}else{
flash = window.document.flashObject;
}
alert(flash);
}
function displayFlashInfo() {
var flashInfo = flash.getFlashInfo();
var i = 0;
for(var key in flashInfo) {
alert(key+": "+flashInfo[key]);
i++;
if (i>3) break;
}
}
//I run addFlashIntegration(); and then displayFlashInfo(); later

This part works fine, but here's the ActonScript code:

import flash.external.ExternalInterface;

function getFlashInfo():Object {
return System.capabilities;
}

ExternalInterface.addCallback("getFlashInfo", this, getFlashInfo);

What should I do? :confused:

atomic
08-05-2007, 01:29 PM
How about the swfobject...

http://blog.deconcept.com/swfobject/

...Rather than Dreamweaver's AC_FL_RunContent() code? Same thing?

shane.carr
10-09-2007, 11:05 PM
Sorry about the delayed response...

I tried the SWFObject script, and it works like a dream! Thank you! :)

atomic
10-10-2007, 12:56 AM
Grrrrrrrrreat! ;)