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.
Printable View
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.
welcome to FK... i dont understand the question..wot are you trying to do exactly?
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!
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
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..
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;
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);
}
Well took some doing. Im am still new to AS3. But here is the code.
It works, but let me know if it can be made simplerCode://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;
I dont think we need to import the FileReference class if we are placing the code on the timeline.
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;
OMG, you guys are amazing. I'm going to test it out! *blown away*