Error calling method on NPObject
It seems not to be working:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="300" id="externalInterface" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="sgame.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="sgame.swf" quality="high" bgcolor="#ffffff" width="600" height="300" name="externalInterface" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflas开发者_JS百科hplayer" />
</object>
And in the AS3 code:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("retrieveChar", function(theData){
//stuff
});
Here is the JavaScript:
document['externalInterface'].retrieveChar('test');
I can't see anything wrong with it.
Looks like you are missing a ) ExternalInterface.addCallback("retrieveChar", function(theData)) <--??
I have done similar things with http://code.google.com/p/swfobject/wiki/api and found it quite helpful.
For future reference, I figured it out. I had a syntax error in the ActionScript code (not found by the AS3 compiler), and it messed up the reference to the function.
精彩评论