Download button

Hi

I have a few buttons rigged up for downloading word.doc, mp3 etc

Problem is its opening the file rather than giving a download this file option.

I though this was simple :asleep:

File Reference Class homie :slight_smile:

erm any alternatives to filereference? or not

You can use a server side script to force the download prompter by just passing the file value. I did this once in ASP, I don’t have access to the files but a google search will probably help.

or you could stick everything in zips… mp3s can go to hell lol

I was getting authorisation/sandbox issues issues /else/or

it played int default player

I’m sure I could figure it out but :stuck_out_tongue:


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://www.macromedia.com/platform/whitepapers/platform_overview.pdf";

this.onMouseDown = function () { // or some buttonInstanceName.onPress = function {
	if (!fileRef.download (url, "FlashPlatform.pdf")) {
		trace ("dialog box failed to open.");
	}
};

yup

I still get a security issue, just easier to use zips