Skip to main content
Known Participant
April 10, 2012
Question

How to Add a Linefeed to the Very End of a TextFrame's Contents

  • April 10, 2012
  • 1 reply
  • 735 views

(IND 5.0, Actionscript)

Hi all,

I need to be able to add a linefeed ("\n") to the very end of a TextFrame's contents, which may include any combination of tagged and untagged texts, and tagged and untagged image frames.

There seems to be an endless variation of circumstances, each of which require a specific solution.

For example:

  • If the last run of the Text is tagged, then I need to append the "\n" to the that last tag's contents.
  • If there are no Tags in the Text, then I can append the "\n" to the TextFrame's contents.
  • If the TextFrame is Tagged, but the last letter(s) in the Text are untagged - I don't know what to do.
  • If the last object in the TextFrame is an Image Frame, then I don't know what to do (you can't add the "\n" to an image's contents).

In short, is there some catch-all solution for adding a "\n" at the very end of a TextFrame's contents, without the Tags on the Text being removed and without causing a failure due to trying to add "\n" to an Image's contents?

TIA,

mlavie

This topic has been closed for replies.

1 reply

mlavieAuthor
Known Participant
April 16, 2012

1) Bump

2) I think this questioni has "harbs." written all over it...

mlavie

Harbs.
Legend
April 16, 2012

Harbs is crazy busy right now, and I don't really understand your issue.

Why do you need to add a linefeed? Do you mean a paragraph return or soft return?

Something like this might be what you are after:

textFrame.insertionPoints.item(-1).contents = "\r";

or

textFrame.insertionPoints.item(-1).contents = SpecialCharacters.FORCED_LINE_BREAK;

Harbs