2013-08-05 70 views
0

該文件正在正確上傳,並且我的ProgessEvent.Progress方法顯示100%完整,但是我的Event.Complete方法未觸發。我需要從服務器發回特定的東西嗎?我只是發回一個成功的消息。我沒有收到任何錯誤。如何獲取文件上傳中的Event.Complete事件以在Flash Builder中觸發

我想我可以在進度方法達到100%時繼續。在發送數據並從服務器收到響應之後,Event.Complete方法不應該觸發嗎?

* *更新:我得到一個錯誤與我Event.Complete方法....

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::[email protected] to flash.events.DataEvent.

*我改變我的onLoadComplete(事件:DataEvent)解決了這一問題的方法的onLoadComplete(事件:事件)。錯誤消失了,我的方法現在正在解僱。系統允許我回答自己的問題。

相對碼如下:

fileRef = new FileReference(); 
fileRef.addEventListener(Event.SELECT, onFileSelected); 
fileRef.addEventListener(Event.COMPLETE, onUploadComplete); 
fileRef.addEventListener(ProgressEvent.PROGRESS,onUploadProgress); 
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onUploadError); 
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadError); 

private function onUploadProgress(event:ProgressEvent):void { 
    status = ((event.bytesLoaded * 100)/event.bytesTotal).toString(); 

} 

private function onUploadComplete(event:DataEvent): void { 
    status = "Complete"; 
} 

private function onUploadError(event:Event):void { 
    if (event is IOErrorEvent) { 
     Alert.show((event as IOErrorEvent).text.toString()); 
    } else if (event is SecurityErrorEvent) { 
     Alert.show((event as SecurityErrorEvent).text.toString()); 
    } else { 
     status = "Unknown error"; 
    } 
} 

回答

0

我改......

private function onUploadComplete(event:DataEvent):void { 
    status = "Complete: "+event.toString(); 
} 

要...

private function onUploadComplete(event:Event):void { 
    status = "Complete: "+event.toString(); 
} 

我猜這是因爲我沒有將數據發送回,只有一個簡單的xml塊。希望這可以幫助別人。

相關問題