sendToURL无法在flashplayer 14中工作

时间:2014-10-30 10:21:12

标签: actionscript-3 flex actionscript flex3

这段代码在flashplayer 11中有效,但它在flashplayer 14中无效。

AS3代码:

private function savePDF(pdfBinary:ByteArray, urlString:String):void{

try{

    //result comes back as binary, create a new URL request and pass it back to the server
    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

    var sendRequest:URLRequest = new URLRequest(urlString);
        sendRequest.requestHeaders.push(header);
        sendRequest.method = URLRequestMethod.POST;
        sendRequest.data = pdfBinary;                
        sendToURL(sendRequest);

    } catch (e:Error) {
        // handle error here
        trace("Error in savePDF "+e.message);
        trace("StackTrace : "+e.getStackTrace());
    }

} 

这些是我得到的错误:

Error in savePDF Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
StackTrace : SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
    at global/flash.net::sendToURL()
    at Export2Publish/savePDF()[my_project_dir\src\Export2Publish.mxml:158]
    at Export2Publish/GeneratePDF()[my_project_dir\src\Export2Publish.mxml:386]
    at Export2Publish/getUrl()[my_project_dir\src\Export2Publish.mxml:138]
    at Export2Publish/___Export2Publish_Application1_creationComplete()[my_project_dir\src\Export2Publish.mxml:3]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[my_framework_dir\src\mx\core\UIComponent.as:9051]
    at mx.core::UIComponent/set initialized()[my_framework_dir\src\mx\core\UIComponent.as:1167]
    at mx.managers::LayoutManager/doPhasedInstantiation()[my_framework_dir\src\mx\managers\LayoutManager.as:698]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[my_framework_dir\src\mx\core\UIComponent.as:8460]
    at mx.core::UIComponent/callLaterDispatcher()[my_framework_dir\src\mx\core\UIComponent.as:8403]

针对此问题的任何修复?

1 个答案:

答案 0 :(得分:1)

您可以首先使用trycatch开头:

try {
    sendToURL(request);
}
catch (e:Error) {
    // handle error here
}

如果在开发环境中看不到问题,我建议您安装一个Flash调试播放器,您可以在此处下载:Flash Player Downloads以查看您的代码将触发的错误类型。

如果您的代码没问题,那么在dev和prod环境中,您应该调试服务器端脚本。