Ste*_*pes 2 flash error-handling actionscript-3
我正在开发一个使用URLLoader从远程服务器获取信息的Flash应用程序.我有一个函数,它将根据产品ID创建信息请求.当出现错误时,我想回到备用URL,但要创建备用URL,我需要知道产品ID.确定哪个URLLoader失败(以及哪个产品请求失败)以便我可以重新生成新URL的最佳方法是什么?
我的功能如下:
function loadData(productID:String):URLLoader {
var productURL:URLRequest = new URLRequest("/path/to/product/" + productID);
var dataLoader:URLLoader = new URLLoader();
dataLoader.addEventListener(Event.COMPLETE, parseData);
dataLoader.addEventListener(IOErrorEvent.IO_ERROR, handleDataError);
dataLoader.load(productURL);
return dataLoader;
}
function handleDataError(e:IOErrorEvent) {
var productID:String = ???;
var altProductURL:URLRequest = new URLRequest("/alternate/path/to/product/" + productID);
var dataLoader:URLLoader = new URLLoader();
dataLoader.load(altProductURL);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |