4 Replies Latest reply on Oct 19, 2010 8:23 AM by Emanuele Radaelli

    [CS5 - JS] ID scripting problem in Flash Builder 4

    Emanuele Radaelli Level 1

      Hi guys,

      I know it may look out of topic but it's a matter of InDesign scripting so I don't know how to post it if not here...

      I'm developing an InDesign Extension using ExtensionBuilder libraries in Flash Builder 4 so basically I'm doing some Jscripting within Flash.

      I don't know how many of you are aware of what it's like but it's the same thing as scripting with ETK but with typed variables.

      Everything is going all right except for one thing.

      I need to build an XML with all text contained in my document.

      The problem is that if a text content is a SpecialCharacter (for instance a Current Page Number...) it will return nothing so I have to make a routine to check every SpecialCharacter and replace it with its real value:

       

      for(var k = 0; k < parag.characters.length; k++){

           var car = parag.characters.item(k);

           if(car.contents == SpecialCharacters.AUTO_PAGE_NUMBER){

                  var pagina = car.parentTextFrames[0].parent.pages.firstItem().name;

                  var IP = car.insertionPoints.firstItem();

                  IP.contents = pagina;

                  car.remove();

              }

          }

          parag.recompose();

      }

       

      Pretty simple.

      I wrote this code in ETK and it works.

      I wrote it in Flash Builder as follows:

       

      for(var k:int = 0; k < parag.characters.length; k++){

       

       

           var car:Character = parag.characters.item(k);

           if(car.contents == SpecialCharacters.AUTO_PAGE_NUMBER){

                  var pagina:Page = car.parentTextFrames[0].parent.pages.firstItem().name;

                  var IP:InsertionPoint = car.insertionPoints.firstItem();

                  IP.contents = pagina;

                  car.remove();

              }

          }

          parag.recompose();

      }

       

      The problem (in Flash Builder) is that when a character is a Special Character car.contents do not return anything.

      I tried to set car variable as Text or as Object but it doesn't work.

      Does anybody have some suggestion?

       

      Thanks