Adobe® Flex® 4 Language Reference
Show Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flashx.textLayout.factory 
StringTextLineFactory 
Packageflashx.textLayout.factory
Classpublic final class StringTextLineFactory
InheritanceStringTextLineFactory Inheritance TextLineFactoryBase Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The StringTextLineFactory class provides a simple way to create TextLines from a string.

The text lines are static and are created using a single format and a single paragraph. The lines are created to fit in the specified bounding rectangle.

The StringTextLineFactory provides an efficient way to create TextLines, since it reuses single TextFlow, ParagraphElement, SpanElement, and ContainerController objects across many repeated invocations. You can create a single factory, and use it again and again. You can also reuse all the parts that are the same each time you call it; for instance, you can reuse the various formats and the bounds.

Note: To create static lines that use multiple formats or paragraphs, or that include inline graphics, use a TextFlowTextLineFactory and a TextFlow object.

View the examples

See also



Public Properties
 PropertyDefined By
 InheritedcompositionBounds : Rectangle
The rectangle within which text lines are created.
TextLineFactoryBase
  configuration : IConfiguration
[read-only] The configuration used by the internal TextFlow object.
StringTextLineFactory
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  defaultConfiguration : IConfiguration
[static] [read-only] The default configuration used by this factory if none is specified.
StringTextLineFactory
 InheritedhorizontalScrollPolicy : String
Specifies how lines are created when the composition bounds are not large enough.
TextLineFactoryBase
 InheritedisTruncated : Boolean
[read-only] Indicates whether text was truncated when lines were last created.
TextLineFactoryBase
  paragraphFormat : flashx.textLayout.formats:ITextLayoutFormat
The paragraph format.
StringTextLineFactory
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  spanFormat : flashx.textLayout.formats:ITextLayoutFormat
The character format.
StringTextLineFactory
 InheritedswfContext : ISWFContext
The ISWFContext instance used to make FTE calls as needed.
TextLineFactoryBase
  text : String
The text to convert into TextLine objects.
StringTextLineFactory
  textFlowFormat : flashx.textLayout.formats:ITextLayoutFormat
The text flow format.
StringTextLineFactory
 InheritedtruncationOptions : flashx.textLayout.factory:TruncationOptions
Specifies the options for truncating the text if it doesn't fit in the composition bounds.
TextLineFactoryBase
 InheritedverticalScrollPolicy : String
Specifies how lines are created when the composition bounds are not large enough.
TextLineFactoryBase
Public Methods
 MethodDefined By
  
Creates a StringTextLineFactory object.
StringTextLineFactory
  
Creates TextLine objects using the text currently assigned to this factory object.
StringTextLineFactory
 Inherited
The smallest rectangle in which the layed-out content fits.
TextLineFactoryBase
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

configuration

property
configuration:IConfiguration  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The configuration used by the internal TextFlow object.



Implementation
    public function get configuration():IConfiguration

defaultConfiguration

property 
defaultConfiguration:IConfiguration  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The default configuration used by this factory if none is specified.



Implementation
    public static function get defaultConfiguration():IConfiguration

paragraphFormat

property 
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The paragraph format.



Implementation
    public function get paragraphFormat():flashx.textLayout.formats:ITextLayoutFormat
    public function set paragraphFormat(value:flashx.textLayout.formats:ITextLayoutFormat):void

spanFormat

property 
spanFormat:flashx.textLayout.formats:ITextLayoutFormat

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The character format.



Implementation
    public function get spanFormat():flashx.textLayout.formats:ITextLayoutFormat
    public function set spanFormat(value:flashx.textLayout.formats:ITextLayoutFormat):void

text

property 
text:String

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The text to convert into TextLine objects.

To produce TextLines, call createTextLines() after setting this text property and the desired formats.



Implementation
    public function get text():String
    public function set text(value:String):void

textFlowFormat

property 
textFlowFormat:flashx.textLayout.formats:ITextLayoutFormat

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The text flow format.



Implementation
    public function get textFlowFormat():flashx.textLayout.formats:ITextLayoutFormat
    public function set textFlowFormat(value:flashx.textLayout.formats:ITextLayoutFormat):void
Constructor Detail

StringTextLineFactory

()Constructor
public function StringTextLineFactory(configuration:IConfiguration = null)

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

Creates a StringTextLineFactory object.

Parameters
configuration:IConfiguration (default = null) — The configuration object used to set the properties of the internal TextFlow object used to compose lines produced by this factory.
Method Detail

createTextLines

()method
public function createTextLines(callback:Function):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

Creates TextLine objects using the text currently assigned to this factory object.

The text lines are created using the currently assigned text and formats and are composed to fit the bounds assigned to the compositionBounds property. As each line is created, the factory calls the function specified in the callback parameter. This function is passed the TextLine object and is responsible for displaying the line.

To create a different set of lines, change any properties desired and call createTextLines() again.

Parameters

callback:Function — The callback function called for each TextLine object created.

StringTextLineFactory_example.as

The following example uses the StringTextLineFactory to create a set of text lines from a string. The factory method, createTextLines() is called twice using the same phrase. The factory properties are adjusted between calls to create a "drop shadow" effect.
package flashx.textLayout.factory.examples {
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.geom.Rectangle;
    
    import flashx.textLayout.factory.StringTextLineFactory;
    import flashx.textLayout.formats.TextLayoutFormat;

    public class StringTextLineFactory_example extends Sprite
    {
        public function StringTextLineFactory_example()
        {
            var factory:StringTextLineFactory = new StringTextLineFactory();
            factory.compositionBounds = new Rectangle( 100, 100, 200, 130 );
            var format:TextLayoutFormat = new TextLayoutFormat();
            format.fontFamily = "LilyUPC, Verdana, _sans";
            format.fontSize = 32;
            format.color = 0x000000;
            format.textAlpha = .5;
            factory.spanFormat = format;
            
            factory.text = "The quick brown fox jumped over the lazy dog.";
            factory.createTextLines( useTextLines );
            
            factory.compositionBounds = new Rectangle( 99, 99, 200, 130 );
            format.color = 0x990000;
            format.textAlpha = 1;
            factory.spanFormat = format;
            factory.createTextLines( useTextLines );
            
            graphics.beginFill(0x555555,.5);
            graphics.drawRect( 99, 99, 201, 131 );
            graphics.endFill();

        }
        
        private function useTextLines( line:DisplayObject ):void
        {
            var displayObject:DisplayObject = this.addChild( line );
        }
    }
}