Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flashx.textLayout.conversion 
PlainTextExporter 
Packageflashx.textLayout.conversion
Classpublic class PlainTextExporter
InheritancePlainTextExporter Inheritance Object
Implements ITextExporter

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

Export filter for plain text format. This class provides an alternative to the TextConverter.export() static method for exporting plain text, useful if you need to customize the export by changing the paragraphSeparator or stripDiscretionaryHyphens options. 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 paragraphSeparator and the stripDiscretionaryHyphens 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
  paragraphSeparator : String
Specifies the character sequence used (in a text flow's plain-text equivalent) to separate paragraphs.
PlainTextExporter
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  stripDiscretionaryHyphens : Boolean
This flag indicates whether discretionary hyphens in the text should be stripped during the export process.
PlainTextExporter
Public Methods
 MethodDefined By
  
Constructor
PlainTextExporter
  
Export the contents of a TextFlow object to plain text.
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. 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 flag 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 the stripDiscretionaryHyphens 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, The default value is true.



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

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

Export the contents of a TextFlow object to plain text. The values of the paragraphSeparator and the stripDiscretionaryHyphens properties affect the output produced by this method.

Parameters

source:flashx.textLayout.elements:TextFlow — the text flow object to export
 
conversionType:String — The type to return (STRING_TYPE). This parameter accepts only one value: ConversionType.STRING_TYPE, but is necessary because this class implements the ITextExporter interface. The interface method, ITextExporter.export(), requires this parameter.

Returns
Object — Object the exported content

See also

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