by Robin Briggs

 Comments (5)

Created

January 22, 2011

There are a lot of cases where you might want to add additional DisplayObjects to the line when it is displayed. Sometimes these are called decorations or ornaments. We got this example from one of our users, Will Lin of Silicon Publishing. Will wanted to have a bulleted list, but he needed his list to work with TLF 1.1, which doesn’t have list support. So he added a decoration to the lines that adds the bullet at the start of the paragraph. Here’s how it works.

TLF’s ContainerController class takes the TextLines generated from composition and adds them to the container. To do this, it has a function, addTextLine, that is called on each TextLine as it is added. Will made a new class, BulletsContainerController, that inherits from ContainerController and overrides the addTextLine method. For each line that is added, he checks to see if the line is at the beginning of the paragraph. If it is, he generates a new DisplayObject for the bullet and makes it a child of the TextLine.

In the main body of his application, when he creates the TextFlow, instead of adding a controller that is a ContainerController instance he adds a BulletContainerController instead.

That’s pretty much all there is to it. Thanks to Will and to Silicon Publishing for making this example public!

BulletsExample

COMMENTS

  • By Zoltan - 10:02 AM on January 22, 2011   Reply

    Hi,
    the download link is broken. Can you fix it plz.

    Thx.

  • By dada - 11:57 AM on January 23, 2011   Reply

    Example link is broken. Please fix it.

  • By Jason Stafford - 4:28 PM on January 24, 2011   Reply

    +1

  • By Jason Stafford - 4:29 PM on January 24, 2011   Reply
  • By Oz DiGennaro - 11:38 PM on February 1, 2011   Reply

    This whole series is very useful and adds information to the formal documentation – just the info that I need.
    Thanks very much,
    Oz

ADD A COMMENT