I'm extremely confused, I've taken a whole day to do something that should be very easy. I just want to call a Flash function from JavaScript - that's it.
ActionScript Code:
import flash.display.Loader;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.net.FileReference;
import flash.events.IOErrorEvent;
import flash.events.Event;
import flash.system.Security;
Security.allowDomain("*");
ExternalInterface.addCallback("test", test);
function test()
{
ExternalInterface.call("alert", "Doesn't Work");
}
JavaScript/HTML
<h1>Test</h1>
<script>
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function poc() {
getFlashMovie( "Test" ).test();
}
</script>
<button onclick="poc()">Click Me!</button>
This doesn't work, the function 'test' does not exist for object 'Test'
I thought I'd ask here as a last ditch effort. Here's my live example: http://itsclassified.info/flash/Test.html
Here is some js code of the given page http://itsclassified.info/flash/Test.html
<object type="application/x-shockwave-flash" data="Test.swf" name="POC" width="1" height="1">
<param name="movie" value="Test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
Try to change
name="POC"
to
name="Test"
I have test it in chrome and IE11, it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.