Example: Newspaper-style text formatting

The News Layout example formats text to look something like a story in a printed newspaper. The input text can contain a headline, a subtitle, and the body of the story. Given a display width and height, this News Layout example will format the headline and the subtitle to take the full width of the display area. The story text will be distributed across two or more columns.

This example illustrates the following ActionScript programming techniques:

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The News Layout application files can be found in the folder Samples/NewsLayout. The application consists of the following files: <table updated: 6/20/2007>

File

Description

NewsLayout.mxml

or

NewsLayout.fla

The user interface for the application for Flex (MXML) or Flash (FLA).

StoryLayout.as

The main ActionScript class that arranges all the components of a news story for display.

FormattedTextField.as

A subclass of the TextField class that manages its own TextFormat object.

HeadlineTextField.as

A subclass of the FormattedTextField class that adjusts font sizes to fit a desired width.

MultiColumnTextField.as

An ActionScript class that splits text across two or more columns.

story.css

A CSS file that defines text styles for the layout.

Subtopics

Reading the external CSS file
Arranging story elements on the page
Altering font size to fit the field size
Splitting text across multiple columns

Flash CS3