BETA ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Hide Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes

Language Reference only
Filters: Retrieving Data from Server...
Retrieving Data from Server...
flashx.textLayout.conversion 

PlainTextExporter  - AS3

(Beta)
Packageflashx.textLayout.conversion
Classpublic class PlainTextExporter
InheritancePlainTextExporter Inheritance ConverterBase Inheritance 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
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritederrors : 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
 InheritedthrowOnError : Boolean
ConverterBase
 InheriteduseClipboardAnnotations : Boolean
ConverterBase
Public Methods
 MethodDefined By
  
Constructor
PlainTextExporter
  
Export text content from a TextFlow instance in String, or XML, or a user defined format.
PlainTextExporter
 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

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
PlainTextExporter_example.as

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