1 Reply Latest reply on Sep 30, 2010 9:18 PM by LLDLLDLLD

    encodeURI for file URI: Space Character in Filenames




      I make use of the loader class to load images from the file system:


                      loader.load(new URLRequest(encodeURI(f.url)));


      f is of type File and taken from a File.browseForOpen dialog.


      However, in case the filename of the selected file contains space characters, the statement above will not return any result - it just hangs...


      Is this by design? What is the best way to get around this?


      Best regards



        • 1. Re: encodeURI for file URI: Space Character in Filenames
          LLDLLDLLD Level 1

          OK, I found a solution (link: http://techblog.floorplanner.com/2009/05/04/load-modify-and-save-local-images-with-flash-p layer-10/):


          It uses a FileReference, plus a Loader to load from the data member of the FileReference object. This way it also works with filenames containing space characters.







          private function loadFile():void {
                          loadFileRef = new FileReference();
                          loadFileRef.addEventListener(Event.SELECT, onFileSelect);


          private function onFileSelect(e:Event):void {
                          loadFileRef.addEventListener(Event.COMPLETE, onFileLoadComplete);


          private function onFileLoadComplete(e:Event):void {
                             var loader:Loader = new Loader();
                             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onDataLoadComplete);

                          loadFileRef = null;


          private function onDataLoadComplete(e:Event):void {
                          var bitmapData:BitmapData = Bitmap(e.target.content).bitmapData;