6 Replies Latest reply on May 9, 2013 8:34 AM by Ashif_22khan

    broseForDirectory() crashes Indesign.

    Ashif_22khan

      Hi All,

       

      when i am trying to call browseForDirectory() method from my extension it carshes the indesign, I am a newbee in extension development, please suggest.

      I am also handling select and cancle events in my code. for reference i am also posting the code that i am using to do that.

       

       

        var cFileReference:File = File.desktopDirectory;

                                              cFileReference.browseForDirectory(File.desktopDirectory.nativePath);

                                              cFileReference.addEventListener(Event.SELECT,fileReferenceSelect);

                                              cFileReference.addEventListener(Event.CANCEL,fileReferenceCancel);

       

       

      Thanks

      Ashif

        • 1. Re: broseForDirectory() crashes Indesign.
          Harbs. Adobe Community Professional & MVP

          This is  a known bug. I use the ExtendScript file browsing functionality as a workaround. (Folder.selectDialog())

           

          Harbs

          • 2. Re: broseForDirectory() crashes Indesign.
            Ashif_22khan Level 1

            @Habs

            Can you please explain how to do that?

            • 3. Re: broseForDirectory() crashes Indesign.
              Harbs. Adobe Community Professional & MVP

              Create an ExtendScript function like this:

               

              function browseForDirectory(title){
                   var f = Folder.selectDialog(title);
                   if(!f){
                        return "";
                   }
                   if(File.fs == "Macintosh"){
                        return f.absoluteURI;
                   } else {
                        return f.fsName;
                   }
              }
              

               

              From ActionScript you do this:

               

              var filePath:String = jsxInterface.browseForDirectory("Gimme some folder, dude!");
              if(filePath){
                   var myFolder:File = new File(filePath);
                   // go mess with the folder...
              }
              
              • 4. Re: broseForDirectory() crashes Indesign.
                Ashif_22khan Level 1

                @Harbs

                Thanks alot.

                • 5. Re: broseForDirectory() crashes Indesign.
                  kc2scy Level 1

                  Hi Harps,

                   

                  this is interesting. were do you place the extend script file?

                  within the scipt folder or is t part of plug-in package.

                  • 6. Re: broseForDirectory() crashes Indesign.
                    Ashif_22khan Level 1

                    @kc2scy

                    You have to place your jsx file inside the resource of your app.

                    here is a sample

                     

                    [Embed (source= "Resources/Browse.jsx" , mimeType= "application/octet-stream" )]

                                        private static var myScriptClass:Class;

                                        public static function runTwo():String {

                                                  var jInterface:HostObject = HostObject.getRoot(HostObject.extensions[0]);

                                                  var path:String="";

                                                  try{

                                                            var path:String=jInterface.eval( new myScriptClass().toString());

                                                  }catch(e){

                                                            return "";

                                                  }

                                                  return path;

                                        }