as2中ExternalInterface.call调用不到JS
如题,我想得到JS中的返回值。
as中:
on (rollOver) {
//flash.external.ExternalInterface.call("getLots");
flash.external.ExternalInterface.call("alert");
//getURL("javascript:alert('我想我是海!')");
//getURL("javascript:getLots('我想我是海')");
}
使用getURL可以调用如:
getURL("javascript:getLots('我想我是海')");
而用ExternalInterface.call无反应如:
flash.external.ExternalInterface.call("getLots");
js中:
function getLots(){
alert("in");
return "800";
}
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="100%" height="100%" id="map_sz" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="./dynamicbusiness_new/map_sz.swf" /><param name="quality" value="best" /><param name="scale" value="exactfit" /><param name="bgcolor" value="#ffffff" /> <embed src="./dynamicbusiness_new/map_sz.swf" quality="best" scale="exactfit" bgcolor="#ffffff" width="100%" height="100%" name="map_sz" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer_cn" />
</object>
谢谢!
------解决方案--------------------
刚看了下发现在*按钮元件*动作* typeof ExternalInterface 为 undefined..
点击 *ActionScript 设置* 显示为 flash player7.0 ActionScript1.0不支持此设置.....
然后我在发布设置里 将 flash player7.0 改成 8.0
将 ActionScript1.0 改成 2.0...就行了
然后调用 ExternalInterface.call 要以 flash.external.ExternalInterface.call全名方式
on (rollOver) {
if (flash.external.ExternalInterface.available)
{
flash.external.ExternalInterface.call("alert");
}
test2.text = typeof flash.external.ExternalInterface.call+ "我想我是海!";
}