私は最終的に、私がここで落としたクラスのコードでこの問題の解決策を見つけました。ダウンロードするファイルごとにボタン、進行状況を示す 2 つの同一のバー (mc) ("mc_progress" および "mc_loaded")、およびアクションが完了したことを示すテキスト フィールド (txt_prog.文章)。それでおしまい。ここですべてを見つけることができます:http://dev.tutsplus.com/tutorials/quick-tip-download-files-through-swfs-using-filereference--active-9068
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.events.Event;
public class fileref extends Sprite
{
//Donload Buttons
public var btn_img_download : MovieClip,
btn_txt_download : MovieClip,
btn_mp3_download : MovieClip,
mc_loaded : MovieClip;
//Progress Bar
public var mc_progress : MovieClip,
txt_prog : TextField;
//Download links Array
private var Arr_Links : Array;
//Default Parent Path for Downloads
private var defaultPath : String = "files/";
//Filen Name
private var urlName : String;
//instance of FileReference() Class
private var fr : FileReference;
//url of the requested files
private var req : URLRequest;
public function fileref() : void
{
//Set buttonModes of the download buttons
btn_img_download.buttonMode = btn_txt_download.buttonMode = btn_mp3_download.buttonMode = true;
//Set width of the mc_loaded progress bar to 0
mc_loaded.scaleX = 0;
//Create list of files to be downloaded
Arr_Links = ["myimage.jpg","myaudio.mp3","mytext.rtf"];
req = new URLRequest();
fr = new FileReference();
//Download buttons Event Listeners
btn_img_download.addEventListener( MouseEvent.CLICK,downloadFile );
btn_mp3_download.addEventListener( MouseEvent.CLICK,downloadFile );
btn_txt_download.addEventListener( MouseEvent.CLICK,downloadFile );
fr.addEventListener( ProgressEvent.PROGRESS,progressHandler );
fr.addEventListener( Event.COMPLETE,completeHandler );
}
private function downloadFile( e : MouseEvent ) : void
{
//set the download path to the urlName variable according to clicked Download Button
switch (e.target.name)
{
case "btn_img_download":
urlName = Arr_Links[0];
break;
case "btn_mp3_download":
urlName = Arr_Links[1];
break;
case "btn_txt_download":
urlName = Arr_Links[2];
break;
}
//change text message "progress" to "downloading..." at txt_prog
txt_prog.text = "downloading...";
//Assign url to the req
req.url = defaultPath + urlName;
//Downlaod requested file
fr.download( req );
}
private function progressHandler( event : ProgressEvent ) : void
{
mc_loaded.scaleX = (event.bytesLoaded / event.bytesTotal) ;
}
private function completeHandler( event : Event ) : void
{
//reset progress bar after download is finished
mc_loaded.scaleX = 0;
txt_prog.text = "download finished";
}
}
}