Tôi có một thử nghiệm nhỏ để thử nghiệm gọi hàm ActionScript (3.0) từ JavaScript. Tôi đang sử dụng tài liệu Flash như một tài liệu tham khảo: (http://www.adobe.ca/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000340.html) Khi tải trang web tôi đang trình bày với một lỗi Flash Player:Lỗi bảo mật khi cố gắng gọi hàm ActionScript từ JS
SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file: c:/externalinterface.swf cannot access file: c:\myhtml.html
at flash.external::ExternalInterface$/_initJS()
at flash.external::ExternalInterface$/addCallback()
at externalinterface_fla::MainTimeline/frame1()
Đây là ActionScript:
import flash.external.ExternalInterface
function callMe(name:String):String{
return "busy signal";
}
ExternalInterface.addCallback("myFunction",callMe);
Và JS :
<script type="text/javascript" language="javascript">
function callSwf() {
var callResult = flashObject.myFunction("Nick");
alert(callResult);
}
</script>
Cuối cùng đối tượng HTML:
<object width="550" height="400">
<param name="movie" value="externalinterface.swf">
<embed src="externalinterface.swf" width="550" height="400">
</embed>
</object>
Làm cách nào để giải quyết vấn đề này?
trong html của bạn để bạn có cho phép thực thi tập lệnh không? params.allowscriptaccess = "always" –