View Full Version : copy file air

10-26-2010, 11:27 PM
Hi all
I am running into a bit of a problem. I am building a little air app that lets you select a file and then it will copy it to several directories. now I want the user to be able to browse for the file to be copied. I have this working.

private var fileRef:FileReference;
private function init():void {
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, fileRef_select);
private function browseAndUpload():void {
message.text = "";
private function fileRef_select(evt:Event):void {
trace("file selected "+evt.target.data)

I also have code that will copy a file

private function copyFile():void{
var originalLoc:File = File.desktopDirectory.resolvePath("MyNewFile.txt");
var copyLoc:File = File.desktopDirectory.resolvePath("MyNewFileCopy.txt");

both work on their own but I cant seem to marry the two. I cant get the file path from the FileReference or convert it to file to work with my copy code. This is for an air app. Any help would be great.

10-27-2010, 01:36 AM
ok figured it out cant use filerefrence but can use file and browse
import mx.events.FileEvent;
private var openFile:File = new File()

private function browseAndUpload():void{
openFile.addEventListener(Event.SELECT, onOpenFileComplete);

private function onOpenFileComplete(event:Event):void{
trace("event: "+event.target.nativePath);