Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 使用AS 3.0的多进度条跟踪多个文件上载_Actionscript 3_Flash_File Upload_Progress Bar - Fatal编程技术网

Actionscript 3 使用AS 3.0的多进度条跟踪多个文件上载

Actionscript 3 使用AS 3.0的多进度条跟踪多个文件上载,actionscript-3,flash,file-upload,progress-bar,Actionscript 3,Flash,File Upload,Progress Bar,我想创建多文件上传flash应用程序。我需要知道如何使用多个进度条同时跟踪多个文件上载 创建一个URLLoader并收听进度事件。下面是演示。 其主要思想是创建一个包含FileReference或URLLoader和进度指示器的类 Main.as: package { import flash.display.*; import flash.events.*; import flash.text.*; public class Main extends Spr

我想创建多文件上传flash应用程序。我需要知道如何使用多个进度条同时跟踪多个文件上载

创建一个URLLoader并收听进度事件。

下面是演示。 其主要思想是创建一个包含FileReference或URLLoader和进度指示器的类

Main.as:

package 
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class Main extends Sprite 
    {
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);

            var btnText:TextField = new TextField;
            btnText.autoSize = TextFieldAutoSize.LEFT;
            btnText.text = "Click to upload";
            var btn:SimpleButton = new SimpleButton(btnText, btnText, btnText, btnText);
            addChild(btn);

            btn.addEventListener(MouseEvent.CLICK, onBtnClick);
        }

        private function onBtnClick(e:MouseEvent):void 
        {
            var uploader:Uploader = new Uploader("http://www.yahoo.com/");
            uploader.y = this.height;
            addChild(uploader);
        }
    }

}
Uploader.as:

package  
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;

    public class Uploader extends Sprite 
    {
        private var url:String;
        private var fileRef:FileReference;
        private var text:TextField = new TextField;

        public function Uploader(url:String ) 
        {
            this.url = url;

            text.autoSize = TextFieldAutoSize.LEFT;
            text.text = "..."
            addChild(text);

            fileRef = new FileReference();
            fileRef.browse();
            fileRef.addEventListener(Event.SELECT, onSelect);
        }

        private function onSelect(e:Event):void 
        {
            text.text = fileRef.name + " : starting upload";

            var req:URLRequest = new URLRequest(url);
            req.method = URLRequestMethod.POST;

            fileRef.upload(req, fileRef.name);
            fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress);
            fileRef.addEventListener(Event.COMPLETE, onComplete);
            fileRef.addEventListener(IOErrorEvent.IO_ERROR, onError);
        }

        private function onError(e:IOErrorEvent):void 
        {
            text.text = fileRef.name + " :" + e.text;
        }

        private function onComplete(e:Event):void 
        {
            text.text = fileRef.name + " : Complete";
        }

        private function onProgress(e:ProgressEvent):void 
        {
            text.text = fileRef.name + " : " + e.bytesLoaded + "/" + e.bytesTotal;
        }

    }

}

谢谢你的回复。但我有5个文件要上传。我需要为每个同时上传进度栏。例如,5个文件正在上传,我想看到5个进度条。如何将每个文件与进度条关联。