AS3 UrlLoader不会触发Event.COMPLETE

时间:2015-03-03 10:25:36

标签: actionscript-3 http flash

一切正常,除了Event.Complete ......(这意味着我在服务器端检索好内容,并且进度事件按预期工作)

我有一个处理上传的简单代码。我使用这个课程:https://github.com/Nek-/Multipart.as/blob/master/src/com/jonas/net/Multipart.as

我的代码:

package com.foo.http 
{
    import com.jonas.net.Multipart;
    import flash.net.*;
    import flash.events.*;
    import flash.utils.ByteArray;
    import flash.external.ExternalInterface;

    public class RequestManager
    {
        private var request:Multipart;
        private var loader:URLLoader;

        /**
         * The url can be http://foobar:952/helloworld
         * @param   url
         */
        public function RequestManager(url:String)
        {
            this.loader = new URLLoader();
            this.request = new Multipart(url);

            // This is needed, if we don't set it, the complete event will never be trigger
            // We retrieve some text
            this.loader.dataFormat = URLLoaderDataFormat.TEXT;

            // Events
            this.attachEvents();
        }

        public function getRequest():Multipart
        {
            return this.request;
        }

        public function send():void
        {
            this.loader.load(this.request.request);
        }

        private function attachEvents():void
        {
            this.loader.addEventListener(Event.COMPLETE, this.requestCompleted);
            this.loader.addEventListener(ProgressEvent.PROGRESS, this.requestProgress);
            this.loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.securityError);
            this.loader.addEventListener(IOErrorEvent.IO_ERROR, this.networkError);
        }

        // Of course there is also listener methods (with a trace inside and call to JS, nothing more)
    }
}

知道它来自何处?

1 个答案:

答案 0 :(得分:1)

看起来我的问题不是来自actionscript或flash本身,而是来自我的javascript和firefox上的flash调试器。

相关问题