Go Back   kirupaForum > Flash > Flash IDE

Reply
 
Thread Tools Display Modes
Old 05-14-2008, 02:24 PM   #1
apconti
Registered User
Fla Script Set File Extension with Adobe Air?

Is there way to set the extension of a file using Adobe Air's flash.filesystem?

Using the browseForOpen function you can set the FileFilter, limiting the files types available. However when using browseForSave you can not set a fileFilter or fileExtension. The file extension has to be entered manually in the SaveFileDialog. The File.extension property associated with the selected file is read-only. Does anyone know of a work around or anything that I could do to not enter the file Extension manually.
apconti is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?

Old 07-01-2008, 01:12 PM   #2
solutci
Registered User
I found this work around on Adobe's site:

1. browseForSave - put hint in title bar as to file type
2. on Select: check the extension. If exists and is the correct type, go ahead and save. If there is no extension, or the extension is wrong, then append the correct extension on the end.

In my case, I am saving HTML files out. Here is my onSelect function:

Attach Code

private function beginSave():void {
file = File.desktopDirectory;
file.addEventListener(Event.SELECT,doSaveReport);
file.browseForSave("Save as an HTML file || Don't forget to put .html at the end");
}

private function doSaveReport(evt:Event):void {
file = File(evt.target);

if(!file.extension || file.extension != "html"){
trace("no extension");
file.nativePath += ".html";
}

stream = new FileStream();
stream.open(file,FileMode.WRITE);
stream.writeUTFBytes(setupPrintCSS());
stream.close();
}
solutci is offline   Reply With Quote
Old 02-09-2010, 02:39 PM   #3
Swooter
Swooter - AS/JS/HTML/CSS
 
Swooter's Avatar
You can set a default filename - without extension filter though - using this method:
Code:
function saveFile(e=null):void {
 var $file:File = File.desktopDirectory.resolvePath("untitled1.txt");
 $file.addEventListener(Event.SELECT, onFileSelect);
 $file.browseForSave("Save playlist");
}

function onFileSelect(e):void {
 var $file:File = e.target;
 if ($file.extension != "txt") {
  $file.nativePath += ".txt";
 }
 trace("Saving " + $file.nativePath);
}
//btn_save.addEventListener(MouseEvent.CLICK,saveFile);

__________________

AS / JS / HTML / CSS / PHP
Swooter is offline   Reply With Quote
Reply

Tags
air, extension, savefile


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:45 AM.

SHARE:

SUPPORTERS:

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com