# Download button

**URL:** <https://forum.kirupa.com/t/download-button/263217>\
**Category:** Uncategorized\
**Created:** [June 13, 2008, 1:05pm UTC](https://forum.kirupa.com/t/download-button/263217 "2008-06-13T13:05:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 13, 2008, 1:05pm UTC](https://forum.kirupa.com/t/download-button/263217/1 "2008-06-13T13:05:37Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 13, 2008, 3:07pm UTC](https://forum.kirupa.com/t/download-button/263217/2 "2008-06-13T15:07:33Z")

</div>

File Reference Class homie 🙂

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 16, 2008, 10:38am UTC](https://forum.kirupa.com/t/download-button/263217/3 "2008-06-16T10:38:28Z")

</div>

erm any alternatives to filereference? or not

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 16, 2008, 2:58pm UTC](https://forum.kirupa.com/t/download-button/263217/4 "2008-06-16T14:58:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 16, 2008, 3:33pm UTC](https://forum.kirupa.com/t/download-button/263217/5 "2008-06-16T15:33:18Z")

</div>

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 😛

---

<div class="post-metadata">

**Author:** ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)\
**Post date:** [June 16, 2008, 4:11pm UTC](https://forum.kirupa.com/t/download-button/263217/6 "2008-06-16T16:11:49Z")

</div>

```auto

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.");
	}
};

```

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 17, 2008, 10:58am UTC](https://forum.kirupa.com/t/download-button/263217/7 "2008-06-17T10:58:07Z")

</div>

yup

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