Skip to main content
JF Software
Inspiring
September 9, 2010
Question

textAlignLast Issue

  • September 9, 2010
  • 1 reply
  • 796 views

I'm working with Adobe AIR 2.0, the TLF 2.0, and FlashPlayer 10.1

I'm having some problems with TextAlign.JUSTIFY and textAlignLast.

I'm bringing in some content from another application, and displaying it using a custom class built around a TextFlow. This works well and most common text formatting (bold, italic, font, colour, etc) is displaying correctly. I've created a test document with some Lipsum fields that test each of the justification settings. The document should look like this when rendered:

What I actually get, however, is this:

Note that while full justification and right last line justification have worked correctly, left last line justification and center last line justification (the two fields in the bottom left corner and bottom middle) have not.

My code to set the justifcation is a pretty simple switch, which sets the formatting on a paragraph object:

                switch (Justification)
                {
                    case "LeftAlign":
                        $flowElement.textAlign = TextAlign.LEFT;
                        $flowElement.textAlignLast = undefined;
                        break;
                    case "RightAlign":
                        $flowElement.textAlign = TextAlign.RIGHT;
                        $flowElement.textAlignLast = undefined;
                        break;
                    case "CenterAlign":
                        $flowElement.textAlign = TextAlign.CENTER;
                        $flowElement.textAlignLast = undefined;
                        break;
                    case "LeftJustified":
                        $flowElement.textAlign = TextAlign.JUSTIFY;
                        $flowElement.textAlignLast = TextAlign.LEFT;
                        break;
                    case "RightJustified":
                        $flowElement.textAlign = TextAlign.JUSTIFY;   
                        $flowElement.textAlignLast = TextAlign.RIGHT;
                        break;
                    case "CenterJustified":
                        $flowElement.textAlign = TextAlign.JUSTIFY;
                        $flowElement.textAlignLast = TextAlign.CENTER;
                        break;
                    case "FullyJustified":
                        $flowElement.textAlign = TextAlign.JUSTIFY;
                        $flowElement.textAlignLast = TextAlign.JUSTIFY;
                        break;
                }
            }


And when I select the offending text and trace the formatting settings, I get the expected combinations of textAlign / textAlign last, even though the visual appearance is wrong.

What seems to be happening is that a paragraph with the last line left or center aligned is actually giving that last line full justification. Is this a bug, or a 'feature' [:)] or am I missing something?

Any help much appreciated as always.

Jude Fisher

http://www.jcfx.eu

This topic has been closed for replies.

1 reply

September 9, 2010

I've just tried this with TLF 2.0 in an actionscript class and an AIR 2.0 application, and I'm getting the expected result.

I'm assuming you're calling updateAllControllers after making the format change, and that there's no additional text in the paragraph that's not being shown in the container.

Could you post the entire code for your test document?

JF Software
Inspiring
September 22, 2010

I had some trailing whitespace that was causing this issue. Thanks for your help, Alan.