A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Image Gallery... Save Image to Computer?

  1. #1
    Senior Member
    Join Date
    Feb 2002
    Posts
    272

    Image Gallery... Save Image to Computer?

    Hey all,
    I just wondered if there was a way to save image files in a dynamic gallery? For example... when an image is displayed, a little save icon appears that allows the user to save the jpeg file to their computer. Thanks!
    Woody

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    San Diego, California
    Posts
    421
    I've always wanted to do something like that, but it seems Flash cannot do that. At least not in Flash 8. You probably need some outside C++ script to do somethling like that, but I have no clue on how to do that. Sorry, but that's just how it is.

  3. #3
    Senior Member
    Join Date
    Oct 2004
    Posts
    134
    a simple popup would do where the user is advised to right-click the picture to save it to his computer. another thing you could do is call a server side script (asp/php) that will send the picture to the 'output stream'. this means a download prompt will pop up. the problem with the last option is that an empty window will pop up regardless.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Flash 8 has a download option. So you will be able to do that.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member
    Join Date
    Feb 2002
    Posts
    272
    Cancer, I just downloaded the trial version of 8 to play around... could you elaborate more on the download option in 8? thanks!
    Woody

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I have not yet used it but this is what the help files say:

    PHP Code:
    ActionScript 2.0 Language Reference 
            
      
    ActionScript classes 
    FileReference (flash.net.FileReference) > download (FileReference.download method)  
      
     
     
     

    download (FileReference.download method)
    public 
    download(url:String, [defaultFileName:String]) : Boolean

    Displays a dialog box in which the user can download a file from a remote server
    Flash Player can download files of up to 100 MB

    This method first opens an operating-system dialog box that asks the user to enter a filename and select a location on the local computer to save the fileWhen the user selects a location and confirms the download operation (for exampleby clicking Save), the download from the remote server beginsListeners receive events to indicate the progresssuccess, or failure of the downloadTo ascertain the status of the dialog box and the download operation after calling download(), your ActionScript code must listen for events by using event listeners such as onCancelonOpenonProgress, and onComplete

    When the file has successfully downloadedthe properties of the FileReference object are populated with the properties of the local file and the onComplete listener is invoked.

    Only one browse() or download() session can be performed at a time (because only one dialog box can be displayed at a time).

    This method supports downloading of any file typewith either HTTP or HTTPSYou can also send data to the server with the download() call by appending parameters to the URL, for the server script to parse.

    Note: If your server requires user authenticationonly SWF files that are running in a browser--that isusing the browser plug-in or ActiveX control--can provide a dialog box to prompt the user for a user name and password for authentication, and only for downloads. For uploads using the plug-in or ActiveX control, and for uploads and downloads using the stand-alone or external playerthe file transfer fails

    When using this methodconsider the Flash Player security model

    Not allowed if the calling SWF file is in an untrusted local sandbox
    The default is to deny access between sandboxesA website can enable access to a resource by adding a cross-domain policy file
    For 
    more informationsee the following:

    Chapter 17"Understanding Security," in Learning ActionScript 2.0 in Flash 
    The Flash Player 8 Security white paper at http
    ://www.macromedia.com/go/fp8_security 
    The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/fp8_security_apis 
    AvailabilityActionScript 1.0Flash Player 8

    Parameters
    url
    :String The URL of the file to download to the local computerYou can send data to the server with the download() call by appending parameters to the URL, for the server script to parse. For examplehttp://www.myserver.com/picture.jpg?userID=jdoe

    On some browsersURL strings are limited in lengthLengths greater than 256 characters may fail on some browsers or servers.

    defaultFileName:String [optional] - The default filename displayed in the dialog box, for the file to be downloadedThis string cannot contain the following characters: / \ : * ? " < > | % 

    If you omit this parameter, the filename of the remote URL is parsed out and used as the default. 

    Returns
    Boolean - A value of true if the dialog box in which a user can select a file is displayed. If the dialog box is not displayed, the method returns false. The dialog box could fail to be displayed for any of the following reasons: 

    You did not pass a value for the url parameter. 
    The parameters passed are of the incorrect type or format. 
    The url parameter has a length of 0. 
    A security violation occurred; that is, your SWF file attempted to access a file from a server that is outside your SWF file's security sandbox. 
    Another browse session is already in progress. A browse session can be started by FileReference.browse(), FileReferenceList.browse(), or FileReference.download(). 
    The protocol is not HTTP or HTTPS. 
    Example
    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.");

    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Feb 2002
    Posts
    272
    oh wow... this looks great! Now I've just got to figure out how to use it... eh. thanks Cancer
    Woody

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    If you know of a php file, one can work start with, let us know.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Junior Member
    Join Date
    Sep 2005
    Posts
    2

    Downloading with flash possible

    I know by fact that u can download by using flash 8 I have seen it done but can't remember where as soon as I find it again I'll post it here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center