flashx.textLayout.conversion

# PlainTextExporter - AS3

Package | flashx.textLayout.conversion
Class | public class PlainTextExporter
Inheritance | PlainTextExporter ConverterBase Object
Implements | IPlainTextExporter

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

Export converter for plain text format. This class provides an alternative to the `TextConverter.export()` static method for exporting plain text. The PlainTextExporter class's `export()` method results in the same output string as the `TextConverter.export()` static method if the two properties of the PlainTextExporter class, the `PARAGRAPH_SEPARATOR_PROPERTY` and the `STRIP_DISCRETIONARY_HYPHENS_PROPERTY` properties, contain their default values of `"\n"` and `true`, respectively.

View the examples

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | errors : Vector.<String> [read-only] Errors encountered while parsing. | ConverterBase
|  | paragraphSeparator : String Specifies the character sequence used (in a text flow's plain-text equivalent) to separate paragraphs. | PlainTextExporter
|  | stripDiscretionaryHyphens : Boolean This property indicates whether discretionary hyphens in the text should be stripped during the export process. | PlainTextExporter
|  | throwOnError : Boolean | ConverterBase
|  | useClipboardAnnotations : Boolean | ConverterBase

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | PlainTextExporter() Constructor | PlainTextExporter
|  | export(source:flashx.textLayout.elements:TextFlow, conversionType:String):Object Export text content from a TextFlow instance in String, or XML, or a user defined format. | PlainTextExporter
|  | 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

Public Constants
Hide Inherited Public Constants
Show Inherited Public Constants

| Constant | Defined By
--- | --- | ---

Property Detail

### paragraphSeparator

property

`paragraphSeparator:String`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

Specifies the character sequence used (in a text flow's plain-text equivalent) to separate paragraphs. The paragraph separator is not added after the last paragraph.

This property applies to the `PLAIN_TEXT_FORMAT` exporter.

The default value is "\n".

Implementation
`public function get paragraphSeparator():String`
`public function set paragraphSeparator(value:String):void`

### stripDiscretionaryHyphens

property

`stripDiscretionaryHyphens:Boolean`

Language Version: | ActionScript 3.0-

Runtime Versions: | Flash Player 10, AIR 1.5

This property indicates whether discretionary hyphens in the text should be stripped during the export process. Discretionary hyphens, also known as "soft hyphens", indicate where to break a word in case the word must be split between two lines. The Unicode character for discretionary hyphens is `\u00AD`.

If this property is set to `true`, discretionary hyphens that are in the original text will not be in the exported text, even if they are part of the original text. If `false`, discretionary hyphens will be in the exported text.

Implementation
`public function get stripDiscretionaryHyphens():Boolean`
`public function set stripDiscretionaryHyphens(value:Boolean):void`
Constructor Detail

### PlainTextExporter

()
Constructor

`public function PlainTextExporter()`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

Constructor

Method Detail

### export

()
method

`public function export(source:flashx.textLayout.elements:TextFlow, conversionType:String):Object`

Export text content from a TextFlow instance in String, or XML, or a user defined format.

Set the `conversionType` parameter to either of the following values, or a user defined format in user-defined exporters.

- `flashx.textLayout.conversion.ConversionType.STRING_TYPE`;
- `flashx.textLayout.conversion.ConversionType.XML_TYPE`.

Parameters

| `source:flashx.textLayout.elements:TextFlow` — The TextFlow to export
| `conversionType:String` — Return a String (STRING_TYPE) or XML (XML_TYPE), or any user defined format.

Returns

| `Object` — Object The exported content

Examples How to use this example
PlainTextExporter_example.as
Copy

    package flashx.textLayout.conversion.examples
    {
        import flash.display.Sprite;

        import flashx.textLayout.conversion.ConversionType;
        import flashx.textLayout.conversion.PlainTextExporter;
        import flashx.textLayout.conversion.TextConverter;
        import flashx.textLayout.elements.TextFlow;

        public class PlainTextExporter_example extends Sprite
        {
            public function PlainTextExporter_example()
            {
                var markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
                        "<p><span>Hello, World!</span></p>" +
                        "<p><span>Hello, Hemi" + "\u00AD" + "sphere! </span></p>" +
                        "<p><span>Hello, Hello Continent!</span></p>" +
                        "</TextFlow>";

                var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);

                // first export, using the PlainTextExporter class
                var textExporter:PlainTextExporter = new PlainTextExporter();
                var exportedText:String = textExporter.export(textFlow, flashx.textLayout.conversion.ConversionType.STRING_TYPE) as String;

                // second export, using TextConverter.export() static method is same as first export with default settings
                var exportedTextTextConverter:String = TextConverter.export(textFlow,TextConverter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE) as String;

                // use of PlainTextExporter class allows for custom control of paragraph separators and hyphen interpretation
                // third export, we change the paragraph separator to a carriage return and linefeed combination
                textExporter.paragraphSeparator = "\r\n";
                exportedText = textExporter.export(textFlow, flashx.textLayout.conversion.ConversionType.STRING_TYPE) as String;

                // Discretionary hyphen characters are stripped by default.
                // fourth export, we retain discretionary hyphens by setting the stripDiscretionaryHyphens property to false
                textExporter.stripDiscretionaryHyphens = false;
                var exportedTextWithHyphens:String = textExporter.export(textFlow, flashx.textLayout.conversion.ConversionType.STRING_TYPE) as String;

                // The following should report false after setting stripDiscretionaryHyphens to false
                var bothExportStringsHaveHyphens:Boolean = (exportedText == exportedTextWithHyphens);
            }
        }
    }

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