문제

The file is getting uploaded properly and my ProgessEvent.Progress method is showing 100% complete, but my Event.Complete method does not fire. Do I have to send something specific back from the server? I am simply sending back a success message. I am not getting any errors.

I suppose I could just proceed when the progress method hits 100%. Shouldn't the Event.Complete method be firing after the data is sent and a response is received from the server?

**Update: I am getting an error with my Event.Complete method....

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@1277971f1 to flash.events.DataEvent.

* I fixed the problem by changing my onLoadComplete(event:DataEvent) method to onLoadComplete(event:Event). The error went away and I my method is now firing. I will answer my own question when the system allows me to.

Relative code follows:

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";
    }
}
도움이 되었습니까?

해결책

I changed ...

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

To...

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

I am guessing this is because I am not sending data back, only a simple xml block. Hope this helps someone else.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top