Package | flashx.textLayout.conversion |
Class | public class PlainTextExporter |
Inheritance | PlainTextExporter Object |
Implements | ITextExporter |
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
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.
Property | Defined By | ||
---|---|---|---|
constructor : 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 | ||
prototype : 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 |
Method | Defined By | ||
---|---|---|---|
Constructor
| PlainTextExporter | ||
Export the contents of a TextFlow object to plain text. | PlainTextExporter | ||
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object |
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
PlainTextExporter | () | Constructor |
public function PlainTextExporter()
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Constructor
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.
|
Object — Object the exported content
|
See also
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); } } }
Fri Mar 19 2010, 02:45 AM -07:00