【发布时间】:2019-03-27 08:24:04
【问题描述】:
我有以下代码,它尝试GET 一个公共托管 (AWS S3) 文件。
private function ShowS3Message():void
{
// Attempt to download file from AWS
var descriptor:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = descriptor.namespaceDeclarations()[0];
var url:String = "https://s3.amazonaws.com/some-url/file-" + descriptor.ns::versionLabel.split(".").join("-") + ".txt";
var urlRequest:URLRequest = new URLRequest(url);
// Set up callback function
try{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, awsFetchCallback);
loader.load(urlRequest);
}catch(error:Error){}
}
这是回调函数:
/**
* Callback function for AWS message file
*/
private function awsFetchCallback(event:Event):void
{
var data = event.target.data;
// show dialog
var msb:InformationMessageBox = new InformationMessageBox();
msb.mText = data;
msb.open(this, true);
}
当文件存在时,没有问题,代码运行正常。 当文件不存在时,这会引发 StreamError,尽管有 catch 块。
我错过了什么?
【问题讨论】:
标签: actionscript-3 io actionscript http-get