A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [CS3] Right Click and save button?

  1. #1
    flash chick
    Join Date
    Oct 2007
    Location
    Cali
    Posts
    37

    [CS3] Right Click and save button?

    Anyway to make one? I searched using "right click" but didn't see anything. Yes, I know I can zip the items and it makes users save. I don't want to zip the files.

    Thanks.

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    welcome to FK... i dont understand the question..wot are you trying to do exactly?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    flash chick
    Join Date
    Oct 2007
    Location
    Cali
    Posts
    37
    You know how you can go to a website and "right click" on a file and then select save as? I need help in creating that. I know it's been done before.
    Thank you for welcoming me!

  4. #4
    Member
    Join Date
    Oct 2006
    Location
    tampa, Fl
    Posts
    51
    You can create text, place it on the stage. Go down to the properties tab. See the little Chain link? You can put in a web address in there, so when people click on the text, it will allow them to download the file. Right clicking allows user to "copy link" Basically the same as "save as..." With a button or movie clip, Actionscripting, I think would be the solution to make them a link. I'm not sure about AS3 but, "getURL();" would be it for 2.0
    Last edited by mlewek; 10-20-2007 at 02:48 PM.

  5. #5
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Are you trying to allow the person to save the entire swf file? or a portion of the swf file that they click on?

    I don't know a way of actually pulling something out of the swf file, but you can allow the person to click on an object within the swf and giving them a way of downloading it.

    mlewek's idea of using getUrl is probably the easiest way. clicking an object in the swf file will open another webbrowser window with the actually object in the HTML that the user can then use right click save as.

    You can also use action script to give the user a way to download an object using the fileReference class...

    You can control how the right click button works in flash with the ContextMenu class..

    With enough work, you may be able to add a 'download this' selection in the right click menu by using the two above mentioned classes..
    Last edited by DallasNYC; 10-20-2007 at 09:07 PM.

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    this should do the trick... make sure you are testing it on a server

    Code:
    import flash.net.FileReference;
    var fileRef:FileReference = new FileReference();
    
    var cm:ContextMenu = new ContextMenu();
    cm.customItems.push(new ContextMenuItem("Save As", saveAs));
    
    function saveAs() {
        fileRef.download(_root._url);
    }
    this.menu = cm;
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Very Clean.

    I didn't realize that _root had a _url property.

    Did some research to figure out where it is in AS3.

    I think this is right. (untested)

    Code:
    function saveAs() {
        fileRef.download(this.loaderInfo.url);
    }

  8. #8
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Well took some doing. Im am still new to AS3. But here is the code.

    Code:
    //where code is placed on the maintimeline
    //so 'this' refers to root.
    
    trace(this.loaderInfo.url);
    import flash.net.FileReference;
    var fileRef:FileReference = new FileReference();
    
    var cm:ContextMenu = new ContextMenu();
    var saveAsItem:ContextMenuItem = new ContextMenuItem("Save As");
    cm.customItems.push(saveAsItem);
    saveAsItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, saveAs);
    
    
    function saveAs(event:ContextMenuEvent ):void {
    	var swfURL:URLRequest = new URLRequest(this.loaderInfo.url);
    	fileRef.download(swfURL);
    }
    
    this.contextMenu = cm;
    It works, but let me know if it can be made simpler

  9. #9
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I dont think we need to import the FileReference class if we are placing the code on the timeline.

  10. #10
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Finally, here are two context menus.
    One where you get the ' Download Google' when the user clicks on a movieClip called 'box' on the stage. And One where you get the 'Save As' when you click anywhere else.

    Code:
    //where this is place on the maintimeline so 'this' refers to root.
    //where we have a movieClip on the stage called 'box'
    
    trace(this.loaderInfo.url);
    
    var fileRef:FileReference = new FileReference();
    var cm:ContextMenu = new ContextMenu();
    var cmG:ContextMenu = new ContextMenu();
    
    var saveAsItem:ContextMenuItem = new ContextMenuItem("Save As");
    saveAsItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, saveAs);
    cm.customItems.push(saveAsItem);
    
    var dlIndexItem:ContextMenuItem = new ContextMenuItem("DownLoad Google");
    dlIndexItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, dlIndex);
    cmG.customItems.push(dlIndexItem);
    
    function saveAs(event:ContextMenuEvent ):void {
    	var swfURL:URLRequest = new URLRequest(this.loaderInfo.url);
    	fileRef.download(swfURL);
    }
    
    function dlIndex(event:ContextMenuEvent ):void {
    	var googleURL:URLRequest = new URLRequest ( "http://www.google.com/index.html");
    	fileRef.download(googleURL);
    }
    
    this.contextMenu = cm;
    box.contextMenu = cmG;

  11. #11
    flash chick
    Join Date
    Oct 2007
    Location
    Cali
    Posts
    37
    OMG, you guys are amazing. I'm going to test it out! *blown away*

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