| Text
Rectangle - download
this sample files
Supported
by iceProjector V1.5 only
This
sample shows how to download files from remote web server and how
to management local files using fscommands.

- In
Frame 1, we add the menu items and declare the event handling
frame label:
//
The following command declares the download event handler
frame is labeled with "downLabel", and pass the "downloadProgress"
as the status of the download: Please note
that whenever a portion of remote file is downloaded,
, iceProjector immediately executes
the actionscripts
in
the labeled
frame and pass the download status to the "downloadProgress" variable.
fscommand("fas.event.download",
_target + ".downloadLabel," + _target + ".downloadProgress");
//
The following command start the download process.
fscommand("fas.shell.download",
server + "," +
remotePath +"," + localFile);
-
At
a later frame, we give this frame label name as "downLabel" which
is same as we declare by the fscommand "fas.event.Download" in
frame 1. So whenever the menu items are clicked, iceProjector
will execute the actionscripts in this frame.(But not really
go to that frame)
- Add
the actionscripts in below to handle the download
event in this frame. The variable "downloadProgress" denotes
progress or error message of the download.
//If no error happened, downloadProgress is a number between 0 and 100. // Else, it is a string of the error message if ( !isNan(downloadProgress)) { if (downloadProgress == 100){ downloadButton._visible = true; msg = "Download complete."; statusBar._visible = false; fileListBox.addItem(localFileName , localFile); } else { msg = "Downloading ..." + downloadProgress + "%"; } if (downloadProgress == 0 ) downloadProgress = 1; statusBar.gotoAndStop(downloadProgress); } else { downloadButton._visible = true; statusBar._visible = false; msg = "Error : " + downloadProgress; fscommand("fas.shell.DeleteFile",localFile); }
|