2 Replies Latest reply on Jun 28, 2012 10:52 AM by jmw107

    Moving a frame in relation to another frame JS (CS3)

    jmw107 Level 1

      Hi -- I am stuck on this:


      I have a page that has several text frames. What I need to do is find a text frame that has a specific label ("labelone") and move it so it is in the top left corner of a text frame that has another specific label ("labeltwo"). I only want to do this if their top vertical bound is within 40 pts of each other. There may or may not be several frames on a page that have the same labels. So I want those labeled ("labelone") to move to the appropriate coordinate of those labeled ("labeltwo") if a pair is found within 40 pts of each other.


      This is what I have: Obviously, it will not work as I having trouble pairing the appropriate frames:


      for (a = (my_doc.textFrames.length - 1); a>= 0; a--) {

      if (my_doc.textFrames[a].label == "labeltwo"){   


      for (k = (my_doc.textFrames.length - 1); k>= 0; k--) {

      if (my_doc.textFrames[k].label == "labelone" && my_doc.textFrames[a].geometricBounds[0] - my_doc.textFrames[k].geometricBounds[0] < 40){   

      var mybf = my_doc.textFrames[k];

      var mytloc = my_doc.textFrames[a].geometricBounds[1];

      var mytloc2 = my_doc.textFrames[a].geometricBounds[0];

      var newloc = mybf.geometricBounds[1] - mytloc;

      var newloc2 =  mytloc2 - mybf.geometricBounds[0];

      mybf.move(undefined, [-newloc,newloc2]);







      Any help would be greatly appreciated. thanks