Our SourceForge site now has code and projects for TLF example applications. These were previously only posted here on the TLF blog, now there will be a samples set for every build. The “sdk” folder contains most of these examples, and they are available as a download.
The sdk folder is divided into two main sections, one for applications that only rely on TLF and the Flash Player, and one for applications that use the Flex Framework for their user interface, but otherwise call into TLF directly. The first group are in the “actionscript” folder, and the second group are in the “flex” folder.
The actionscript folder has these applications:
– FTE applications FTEHelloWorld and FTEParagraph. These are very simple applications that create and display simple text content using only the Flash Player (no use of TLF).
– Pagination. This application uses TLF to display a book-length text that is divided into chapters, and allows the user to page through the text, advance or backup by chapters, and resize the window.
– TextLayout. This is a set of applications that use TLF, each illustrating different aspects of the framework:
- ContextMenuText shows how to make custom context menus.
- CustomImportMarkup shows simple import and customization using the Configuration class.
- CustomLinkEventHandler shows how to customize clicks on links.
- EditText shows setting up an editable text component.
- EventMirrorExample shows setting up event handlers on group elements.
- ExplicitFormField shows how to set up form-field style text that doesn’t wrap lines.
- HelloWorld shows setting up a read-only text component based on static text.
- ImportMarkup shows setting up a read-only text component based on markup.
- InlineGraphic creates a graphic that appears inline with the text, and shows how to handle the asynchronous load process and automatic sizing.
- LinkedContainers shows how to flow text from one container to another, for when you want a single text stream to appear in a sequence of rectangular areas.
- LinkEventExample shows how to set up a link to send custom events.
- MultipleColumns has a text with a headline and body text that appears in multiple columns.
- ParagraphBorder shows how to draw an ornament around a paragraph, which requires figuring out the area on the stage that is occupied by the paragraph.
- ParagraphBounds shows how to figure out how much vertical space is required to display a paragraph.
- SelectText shows how to make a very simple read-only selectable text component.
- StaticHelloWorld shows how to use the StringTextLineFactory to display some static text in a string. This is more efficient than the HelloWorld example.
- StaticTextFlow shows how to use the TextFlowTextLineFactory to display a static TextFlow object.
The flex folder has applications that use Flex for the user interface, but call into TLF directly:
- SimpleEditor is an editable text component with simple buttons for setting the font family, font size, text alignment,indent, line spacing, and similar attributes.
- SimpleEditorWithCSS is similar to SimpleEditor, but it also allows setting of the styleName and id, and mapping of these with a CSS stylesheet.
- TextLayoutEditor is a text editor that allows editing of text and almost all attributes you can set in TLF. It uses swcs that are in the other two folders, textLayout_editBar and textLayout_ui.
Building the Sample Code
The code is available as a download, but you can also build it yourself if you prefer. Each folder has a build file in it that you can run from Ant.
So try out these samples, and let us know what you think! If there are additional samples you’d like to see, please let us know what they are.