2 Replies Latest reply on Jan 14, 2012 9:54 AM by Josh000000

    How can I find the index from a specific container?

    Josh000000

      How can I find the index from a specific container?

       

      For example, if I'm traversing through textframes like so (an example, not tested):

       

      var doc = app.activeDocument;
      
      var story = doc.pages[0].textFrames[0].parentStory;
      
      for (var i=0, l=story.textContainers.length; i<l; i++) {
           var textFrame = story.textContainers[i];
           if (textFrame.constructor.name == "TextFrame") {
                
                var lastPara = textFrame.paragraphs.lastItem();        //How can I find the index of this in relation to the story?
                
           }
      }
      

       

      How can I find the index of "lastPara" in relation to the story rather than the current container?

       

       

      I tried:

       

      var newPara = story.paragraphs[lastPara.index];
      

       

      but this results in an invalid object. . .

       

      alert(newPara.isValid);      //returns false