سؤال

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