1 Reply Latest reply on Apr 7, 2012 5:40 PM by A.Liebscher

    FileReference filtering the save as file type

    jetrased Level 1

      Hi

       

      I am wondeirng if anyone can tell me if it is possible to filter/specify the save as types for a fileReference.save().

       

      I know to browse you can set the filetypes

       

      files = new FileReference();

      files.browse(new Array(new FileFilter("Image (*.png)", "*.png")));

       

      However I am looking to be able to set the save as type to say jpg, png, bmp. Is this possible?

        • 1. Re: FileReference filtering the save as file type
          A.Liebscher Level 1

          This seems to work for me....

           

          var file:File = File.desktopDirectory;

          file.browseForSave ("Save as *.your file type");

          file.addEventListener (Event.SELECT, onSaveSelect);

          function onSaveSelect(event:Event):void

          {

               var array:Object = Object(arrCol);

               var saveFile:File = File(event.target);

               var directory:String = saveFile.url;

               if (directory.indexOf(".your file type") == -1)

               {

                    directory +=  ".your file type";

               }

               var file:File = new File(directory);

               var fileStream:FileStream = new FileStream();

               fileStream.open (file, FileMode.WRITE);

               fileStream.writeObject(array);

               fileStream.close ();

          }

          It opens up the save dialog, but you don't have to enter a file type. When you click the save, or select, button it saves as whatever file type you want. If you need help understanding this method, just ask.