package { import flash.display.MovieClip; import flash.net.FileReference; import flash.net.URLRequest; import flash.events.Event; import flash.events.ProgressEvent; import flash.events.IOErrorEvent; public class Main extends MovieClip { // Constants: // Public Properties: public var fileDownload:FileReference; public var url:URLRequest; // Private Properties: // Initialization: public function Main() { trace("main class loaded"); fileDownload = new FileReference(); url = new URLRequest("http://www.votreserveur.com/fichier.zip"); fileDownload.addEventListener(ProgressEvent.PROGRESS, onProgress); fileDownload.addEventListener(Event.COMPLETE, onComplete); fileDownload.addEventListener(IOErrorEvent.IO_ERROR, onError); fileDownload.download(url); } // Public Methods: public function onProgress(event:ProgressEvent):void { trace("chargement en cours : " + event.bytesLoaded / event.bytesTotal); } public function onComplete(event:Event):void { trace("téléchargement terminer"); } public function onError(event:IOErrorEvent):void { trace("Erreur de chargement du fichier"); } // Protected Methods: } }