• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Download button

New Here ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

I have a download button on my site that when its pressed i want a pop up box to appear, where u can choose where to save the file to.
anyone have any ideas on the coding for such a button.
TOPICS
ActionScript

Views

357

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

Try this code - Be sure to name the button instance, file path to where the file is on the server., and the name of the file people see when they click on it.




import flash.net.FileReference;


var fileRef:FileReference = new FileReference();
var url:String = " http://www.YOUR COMPLETE INTERNET ADDRESS GOES HERE";
NAME OF BUTTON INSTANCE.onPress=function(){
fileRef.download(url, "THE NAME OF THE FILE YOU WANT PEOPLE SEE ");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

u have to excuse me im very new to flash.

Tried the code but theres an error

**Error** Scene=Scene 1, layer=button1d, frame=149:Line 4: The class 'flash.net.FileReference' could not be loaded.
var fileRef:FileReference = new FileReference();

Total ActionScript Errors: 1 Reported Errors: 1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

i have to bump this, its becoming quite urgent .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

It looks like maybe you didn't name the "instance" on the button. Also make sure the button is at the end of the timeline with action script at the end too. Let me know.....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

The following example attempts to download a file using the download method. Notice that there are listeners for all of the events.

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



See also
browse (FileReference.browse method), browse (FileReferenceList.browse method), upload (FileReference.upload method)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 07, 2006 Aug 07, 2006

Copy link to clipboard

Copied

LATEST
You will need Flash 8 to use the FileReference class(and you need to output for Flash 8 player).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines