flashx.textLayout.factory

# StringTextLineFactory - AS3

Package | flashx.textLayout.factory
Class | public class StringTextLineFactory
Inheritance | StringTextLineFactory TextLineFactoryBase 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.

Note: The StringTextLineFactory ignores the truncationIndicatorFormat property set in the truncationOptions when truncating text.

View the examples

Related API Elements

TextFlowTextLineFactory

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | compositionBounds : Rectangle The rectangle within which text lines are created. | TextLineFactoryBase
|  | configuration : IConfiguration [read-only] The configuration used by the internal TextFlow object. | StringTextLineFactory
|  | constructor : 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
|  | horizontalScrollPolicy : String Specifies how lines are created when the composition bounds are not large enough. | TextLineFactoryBase
|  | isTruncated : Boolean [read-only] Indicates whether text was truncated when lines were last created. | TextLineFactoryBase
|  | paragraphFormat : flashx.textLayout.formats:ITextLayoutFormat The paragraph format. | StringTextLineFactory
|  | spanFormat : flashx.textLayout.formats:ITextLayoutFormat The character format. | StringTextLineFactory
|  | swfContext : 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
|  | truncationOptions : flashx.textLayout.factory:TruncationOptions Specifies the options for truncating the text if it doesn't fit in the composition bounds. | TextLineFactoryBase
|  | verticalScrollPolicy : String Specifies how lines are created when the composition bounds are not large enough. | TextLineFactoryBase

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | StringTextLineFactory(configuration:IConfiguration = null) Creates a StringTextLineFactory object. | StringTextLineFactory
|  | createTextLines(callback:Function):void Creates TextLine objects using the text currently assigned to this factory object. | StringTextLineFactory
|  | getContentBounds():Rectangle The smallest rectangle in which the layed-out content fits. | TextLineFactoryBase
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object 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.

Note that the scroll policies of the factory will control how many lines are generated.

Parameters

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

Examples How to use this example
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.
Copy

    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 );
            }
        }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00