ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
flashx.textLayout.conversion 

ITextImporter  - AS3

Packageflashx.textLayout.conversion
Interfacepublic interface ITextImporter

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

Interface for importing text content into a TextFlow from an external source. The TextConverter class creates importers with no constructor arguments.

View the examples

Related API Elements



Public Properties
 PropertyDefined By
  configuration : IConfiguration
The configuration property contains the IConfiguration instance that the importer needs when creating new TextFlow instances.
ITextImporter
  errors : Vector.<String>
[read-only] This property contains a vector of error messages as strings after a call to an importer method is the throwOnError property is set to false, which is the default.
ITextImporter
  throwOnError : Boolean
The throwOnError property controls how the importer handles errors.
ITextImporter
  useClipboardAnnotations : Boolean
Controls whether or not the importer should handle the extra information necessary for the clipboard.
ITextImporter
Public Methods
 MethodDefined By
  
Import text content from an external source and convert it into a TextFlow.
ITextImporter
Property Detail

configuration

property
configuration:IConfiguration

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10.2, AIR 2.0

The configuration property contains the IConfiguration instance that the importer needs when creating new TextFlow instances. This property is initially set to null.



Implementation
    public function get configuration():IConfiguration
    public function set configuration(value:IConfiguration):void

Related API Elements

errors

property 
errors:Vector.<String>  [read-only]

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

This property contains a vector of error messages as strings after a call to an importer method is the throwOnError property is set to false, which is the default. If there were no errors, the property returns null. The property is reset on each method call.



Implementation
    public function get errors():Vector.<String>

throwOnError

property 
throwOnError:Boolean

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

The throwOnError property controls how the importer handles errors. If set to true, methods throw an Error instance on errors. If set to false, which is the default, errors are collected into a vector of strings and stored in the errors property, and the importer does not throw.



Implementation
    public function get throwOnError():Boolean
    public function set throwOnError(value:Boolean):void

useClipboardAnnotations

property 
useClipboardAnnotations:Boolean

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

Controls whether or not the importer should handle the extra information necessary for the clipboard. When data comes in from the clipboard, it might contain partial paragraphs; paragraphs that are missing the terminator or newline character. If useClipboardAnnotations is true, the importer marks these partial paragraphs with a ConverterBase.MERGE_TO_NEXT_ON_PASTE attribute. This causes the paste operation to correctly handle merging of the pasted paragraph (and any list or div elements that may include the paragraph) into the text.



Implementation
    public function get useClipboardAnnotations():Boolean
    public function set useClipboardAnnotations(value:Boolean):void

Related API Elements

flashx.textLayout.conversion.ConverterBase.MERGE_TO_NEXT_ON_PASTE
Method Detail

importToFlow

()method
public function importToFlow(source:Object):flashx.textLayout.elements:TextFlow

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

Import text content from an external source and convert it into a TextFlow.

Parameters

source:Object — The data to convert.

Returns
flashx.textLayout.elements:TextFlow — TextFlow Created from the source.
ITextImporterExample.as

This code snippet shows a use of the ITextImporter method to perform repeated imports of formatted text. Note that errors are cleared at the beginning of each call to importToFlow.


package flashx.textLayout.conversion.examples
{
    import flashx.textLayout.conversion.ITextImporter;
    import flashx.textLayout.conversion.TextConverter;
    import flashx.textLayout.elements.TextFlow;
    
    public class ITextImporterExample 
    {
        // Create a new TextFlow based on the markup string
        static public function importAndCheckErrors():TextFlow
        {
            var markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'><p><span>Hello, World</span></p></TextFlow>";
            var importer:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_LAYOUT_FORMAT);
            importer.throwOnError = false;
            var textFlow:TextFlow = importer.importToFlow(markup);
            if (!textFlow)
            {
                var errors:Vector.<String> = importer.errors;
                //deal with import errors
            }
            return textFlow;
        }
    }
}