Home > Flash, Flex, Information > Uploading and Downloading By Actionscript

Uploading and Downloading By Actionscript

Some days before I was trying to uploading and downloading an file using Flash ActionSctipt 2.0…and it’s working fine with this part of code…so might be it will be useful for you…

For Downloading :

import flash.net.FileReference;

var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {

trace(“onSelect: ” + file.name);

}

listener.onCancel = function(file:FileReference):Void {

trace(“onCancel”);

}

listener.onOpen = function(file:FileReference):Void {

trace(“onOpen: ” + file.name);

}

listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {

trace(“onProgress with bytesLoaded: ” + bytesLoaded + ” bytesTotal: ” + bytesTotal);

}
listener.onComplete = function(file:FileReference):Void {

trace(“onComplete: ” + file.name);

}

listener.onIOError = function(file:FileReference):Void {

trace(“onIOError: ” + file.name);

}
var fileRef:FileReference = new FileReference();

fileRef.addListener(listener);

var url:String = http://[yourdomain]/[filename];

if(!fileRef.download(url, “filename“)) {

trace(“dialog box failed to open.”);

}

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: