Skip to main content
Participating Frequently
July 8, 2008
Question

How can I make a .pdf file downloadable?

  • July 8, 2008
  • 7 replies
  • 521 views
I have a button (called lets say button_1). How can I make it download a .pdf file once its clicked? I am using Flash 8, Action Script 2. Thanks!
This topic has been closed for replies.

7 replies

Inspiring
July 9, 2008
Maybe I'm not clear about the way you are getting your URL but why are you putting all this code on the button and not on your main timeline:

button_1.onRelease = function() {
getURL("FlashPlatform.pdf", "_blank")
};
ragtoproyAuthor
Participating Frequently
July 9, 2008
Pdf is only like 200kb in size. Very small
Inspiring
July 9, 2008
Zip up the PDF.


--
Regards
FlashJester Support Team

e. - support@flashjester.com
w. - www.flashjester.com

"This has been one of the most impressive and thoroughly pleasant
experiences of customer support I have ever come across - astounding!"
Director - hedgeapple

ragtoproyAuthor
Participating Frequently
July 9, 2008
ttt
ragtoproyAuthor
Participating Frequently
July 9, 2008
ttt
ragtoproyAuthor
Participating Frequently
July 9, 2008
???
ragtoproyAuthor
Participating Frequently
July 9, 2008
This is the code i have:

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";
if(!fileRef.download(url, "FlashPlatform.pdf")) {
trace("dialog box failed to open.");
}
I have it attached to a button but it doesnt work. If I put this code on the actionscript layer the file downloads as soon as page opens and doesnt wait on you to hit the button to activate the download...not what i want lol