You can change it in the save event as the user could key anything in the save 
dialog and I do not know of any way to hook the key press event in that dialog.

This is some 'old' code to change/force the ext, I originally got idea from 
someone's posting, and change it a bit:


import flash.events.Event;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;

private var documentsDir:File;
private const defaultExtensions:String = "ForcedExt";
private const extensionList:Array = ["ForcedExt"];

public function localSave():void {
    documentsDir = File.desktopDirectory;
    documentsDir.browseForSave("Save As");
    documentsDir.addEventListener(Event.SELECT, localSaveHandler);
}

function localSaveHandler(event:Event):void {
    documentsDir.removeEventListener(Event.SELECT, localSaveHandler);
    var pathArray:Array = File(event.target).nativePath.split(File.separator)
    var originalFileName:String = pathArray.pop();
    var newFileName:String = checkExt(originalFileName);
    pathArray.push(newFileName);
    var newURI:File = new File("file:///" + pathArray.join(File.separator));
    var stream:FileStream = new FileStream();
    stream.open(newURI, FileMode.WRITE);
    // Replace this with your actual file write routine.
    stream.writeUTFBytes("Your file contents");
    stream.close();
}

private function checkExt(fileURI:String):String {
    var fileExtension:String = fileURI.split(".")[1];
    for each(var it:String in extensionList) {
        if (fileExtension == it)
            return fileURI;
    }
    return fileURI.split(".")[0] + "." + defaultExtensions;
}


----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: file extention
> Date: Fri, 26 Jun 2015 22:49:37 -0500
>
> I have a function to handle saving a file for AIR. I'd like it to
> automatically add the extension when saving, is there a way to add that to
> the input when you browseForSave?
>
>
>
> Trevor
>
                                          

Reply via email to