flex生成的swf为什么只能在工程bin-debug目录下才能运行正常,高人帮看看
flex生成的swf为什么只能在工程bin-debug目录下才能运行正常,高人帮看看
[解决办法]
首先,你如果是放本机上在非bin-debug目录下,并调用ExternalInterface的任何属性,都会引发安全沙箱错误;假如你放在服务器上,应该没有错吧,下面是我测试的两个文件,点击button后可以正常返回值:
// html文件
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Hello</title><style>body { margin: 0px; overflow:hidden }</style><script type="text/javascript"> function executeAsFunction(){ var result = document.getElementById("TestNew").asFunction("1", "2"); alert(result); }</script></head><body scroll="no"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="TestNew" width="100" height="100" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> <param name="movie" value="TestNew.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess" value="sameDomain" /> <embed src="TestNew.swf" quality="high" bgcolor="#869ca7" width="100%" height="100%" name="TestNew" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed> </object> <hr/> <button id="btnTest" onclick="executeAsFunction()">TEST</button></body></html>