how i can communicate with my flash app ? i load in my extension flash some like this
myDiv.innerHTML = <object…><param allowScriptAsses… etc …
flash load fine !!! now, i trace my externalInterface method
var flashObject = document.get…("myFlash")
alert(flashObject) <- okey - [embedHtmlObject …
alert(flashObject.myExternalMethod) <- native function its okey !!!
try excute
flashObject.myExternalMethod() and NOTHING !!! ((( externalMEthod not invoked !!! this problem ONLY on windows 7 in fireFox !
on mac os and firefox i use wrapedObject and externalInterface work fine ! but if i try use wrapedObject on windows system - i have error (((
HOW i can use ExternalInterface on windows in firefox correctly ?
First you need to add a callback to your ActionScript code:
flash.external.ExternalInterface.addCallback("myExternalMethod", doSomething);
function doSomething():void
{
//your code
}
If you are using swfObject to embed your flash movie you can use swfobject.getObjectById to detect your swf and call your methods.
swfobject.getObjectById("myFlash").myExternalMethod();
If you are not using swfObject just copy and past the getObjectById method on your JS code:
function getObjectById(objectIdStr) {
var r = null;
var o = getElementById(objectIdStr);
if (o && o.nodeName == "OBJECT") {
if (typeof o.SetVariable != UNDEF) {
r = o;
}
else {
var n = o.getElementsByTagName(OBJECT)[0];
if (n) {
r = n;
}
}
}
return r;
}
And call it by doing:
getObjectById("myFlash").myExternalMethod();
Have a look on this, I actually code a small example on my blog: http://www.nelsond8.com/?p=515