Text Layout Framework: ActionScript Samples

The Text Layout Framework is an ActionScript library that provides text layout functionality. It is built on the Flash text engine available in Flash Player 10. This framework provides support for high quality, typographically rich, flowable text layout with selection, editing, undo, copy-paste, and an XML markup language to dynamically style text.

The Text Layout Framework can be used by any developer who wants to build new text components for Flash Player. It uses pure ActionScript; you can work with it in any Flash Professional or Flex development environment. The library is implemented by the flashx.textLayout.* packages in textLayout.swc.

ActionScript examples

These examples in the actionscript folder of the Text Layout Framework SDK demonstrate techniques for working with the API in ActionScript.

Basic TextFlow

TextLayout/HelloWorld.as Demonstrates creating and displaying a TextFlow.
TextLayout/StaticHelloWorld.as Demonstrates use of a TextLineFactory with a string to create static TextLines.
TextLayout/InlineGraphic.as Extends the HelloWorld example with an inline graphic loaded from a remote web site.

Importer

TextLayout/ImportMarkup.as Demonstrates parsing and displaying TextLayout markup.
TextLayout/StaticTextFlow.as Demonstrates use of a TextLineFactory with parsing of TextLayout markup to create static TextLines.
TextLayout/CustomImportMarkup.as Customizes the Configuration used by the importer to create a TextFlow that manages the Tab key and has a customized default format for links.

Selection and editing

TextLayout/EditText.as Demonstrates parsing TextLayout markup, displaying it and attaching an EditManager so that it can be edited.
TextLayout/SelectText.as Demonstrates parsing TextLayout markup, displaying it, and attaching a SelectionManager so that it can be selected and copied.
TextLayout/ExplicitFormField.as Demonstrates editable form style fields that scroll and do not break except on explicit breaks.
TextLayout/MultipleColumns.as Demonstrates editable multi-column text where the columns resize and adjust number as the window resizes.
TextLayout/MultipleContainerColumns.as Demonstrates editable multi-column text flowing through two containers where the columns resize and adjust number as the window resizes.

Additional features

TextLayout/ParagraphBounds.as

Demonstrates computing the height of a paragraph.

TextLayout/ParagraphBorder.as Demonstrates drawing a border and background on a paragraph.
TextLayout/LinkedContainers.as Demonstrates linked containers.
TextLayout/CustomEventHandler.as Demonstrates how to handle custom user-interaction events in LinkElements.
Pagination/Pagination.as Demonstrates a multi chapter multi page document with fast support for window resizing and switching between pages and chapters.

Flash Text Engine (FTE) examples

FTE/FTEHelloWorld.as Implements the HelloWorld example using direct FTE APIs.
FTE/FTEParagraph.as Demonstrates a paragraph of text, defined with direct FTE APIs, that reflows on window resize.

Building the examples

You can build these examples with Flash Builder 4.

Building in a Flash Builder environment

These steps are for loading the examples into your Flash Builder development environment from the Text Layout Framework ZIP

  1. Open Flash Builder 4.
  2. Switch your workspace to the parent of the Samples folder.
  3. In the Preferences dialog Flex tab, select "Installed Flex SDKs".
  4. Add a recent nightly build version of the Flex Gumbo version of the SDK, and make it the default SDK. Note: Recent builds include the TLF 1.0 release candidate - after Flex 4 ships use that.
  5. Choose File > Import.
  6. In the General tab, select "Existing Projects into Workspace".
  7. Browse to the root folder of the workspace. It is preselected.
  8. Deselect any examples you do not want to import. Do not select "Copy into workspace".
  9. Click Finish. You can now build and run the examples from your development environment.