1 Reply Latest reply on Dec 4, 2006 2:27 AM by duckets

    text spacing

    Level 7
      Not sure if my subject line is accurate but here's what I want to do.

      I have a text sprite that displays some external text. I want the text
      to be centred in a defined area. At the moment, if the text is one line,
      it displays OK. But if it flows onto 2 lines, it isn't centred right.

      So, is the following possible (and if so how):
      * Use Lingo to align my text sprite. So whenthe text is inderted, that
      sprite will align to an invisible shape area.?
      * Determine if the text flows onto 2 lines - so can move the text
      sprite's vertical location by the required amount.
      * Determine if the text is is 1 line and insert a RETURN in teh text if
      it is, to ensure I always have 2 lines. (Not sure if this will give the
      result I'm after).


        • 1. Re: text spacing
          duckets Level 1
          To check if the last character is on the same line as the first character, compare:

          firstCharV = textMem.charPosToLoc(1).locV


          lastCharV = textMem.charPosToLoc(textMem.char.count).locV

          This will give you the vertical distance of the first and last characters in the text member (measured from the top of the member's rectangle).

          You should be able to use these values to adjust the vertical position of your sprite (as in your second option mentioned).

          hope this helps!

          - Ben