| Previous | Next | |
Windows: Flash 8 or 9 AS2.0 SWF + mProjector
3.0; Windows 98/ME/NT Support: Flash 7 SWF + mProjector
2.0;
Macintosh: Flash 8 or 9 AS2.0 SWF + mProjector
2.0; replacing mProjector
1.0 async
mApplication.downloadFile(fileName:String, URL:String, progressObject:Object, progressFunction:String) : NumberfileName - Name of local file where the downloaded file will be saved.
If no path is specified, the working directory is used.
URL - URL of the remote file to be downloaded.
progressObject - Optional object that will be used as this of the progress function.
progressFunction - Progress function that will be called periodically during the download.
A number.; ; WINDOWS ONLY: The number is a download session id. You can abort the download at any time by calling the xref=mApplication.abortFunction() function, passing the downloadSessionId as a parameter.
The Mac version has no return value.
Method; Downloads a remote file onto the local computer.
The following example downloads a random image from a server.
var localFileName = mApplication.getFolder()+mSystem.getPathDelimiter()+"image1.jpg";
var remoteFileName:String = "";
var downloadSuccess:Boolean;
var downloadStr:String = "---";
downloadFile_btn.onPress = function() {
if (isConnected) {
downloadStr = "downloading file...";
remoteFileName = "http://www.screentime.com/temp/"+randRange(1, 12)+".jpg";
mApplication.downloadFile(localFileName, remoteFileName, _root, _root.onProgress);
}
};
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
_root.onProgress = function(read:Number, total:Number) {
downloadStr = "downloading file...";
mApplication.trace("onProgress read: " + read + " total: " + total);
if (total == 0) {
downloadSuccessful = false;
downloadStr = "download failed.";
} else if (read == total) {
if (mFile.fileExists(localFileName)) {
downloadSuccessful = true;
image_mc._xscale = 20;
image_mc._yscale = 18;
image_mc.loadMovie(localFileName);
downloadStr = "download successful.";
} else {
downloadSuccessful = false;
downloadStr = "download failed.";
}
}
}
mApplication.abortFunction(), mApplication.getHostAddress(), mApplication.checkNetConnection(),
Check Connection and Download File, mProjector Class Basics -- mApplication, SWF Desktop Helper (Windows)
| Questions or Feedback? | Previous | Next |