Packageflashx.textLayout.elements
Classpublic class SpanElement
InheritanceSpanElement Inheritance FlowLeafElement Inheritance FlowElement Inheritance Object
Subclasses SpecialCharacterElement

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

The SpanElement class represents a run of text that has a single set of formatting attributes applied. SpanElement objects contain the text in a paragraph. A simple paragraph (ParagraphElement) includes one or more SpanElement objects.

A ParagraphElement will have a single SpanElement object if all the text in the paragraph shares the same set of attributes. It has multiple SpanElement objects if the text in the paragraph has multiple formats.

Default MXML PropertymxmlChildren

See also

ParagraphElement


Public Properties
 PropertyDefined By
 InheritedalignmentBaseline : String
[write-only] CharacterFormat: Specifies the line baseline to which the element baseline specified by the elementBaseline property should align to determine the vertical position of the element on the line.
FlowElement
 InheritedbaselineShift : Object
[write-only] CharacterFormat: Amount to shift the baseline from the elementBaseline.
FlowElement
 InheritedbreakOpportunity : String
[write-only] CharacterFormat: Controls where lines are allowed to break when wrapping text is broken into multiple lines.
FlowElement
 InheritedcffHinting : String
[write-only] CharacterFormat: The type of CFF hinting used for this text.
FlowElement
 InheritedcharacterFormat : ICharacterFormat
CharacterFormat properties applied directly to this element.
FlowElement
 Inheritedcolor : Object
[write-only] CharacterFormat: Color of the text.
FlowElement
 InheritedcomputedCharacterFormat : ICharacterFormat
[read-only] Returns the computed character format attributes that are in effect for this element.
FlowLeafElement
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 InheriteddigitCase : String
[write-only] CharacterFormat: The type of digit case used for this text.
FlowElement
 InheriteddigitWidth : String
[write-only] CharacterFormat: Type of digit width used for this text.
FlowElement
 InheriteddominantBaseline : String
[write-only] CharacterFormat: Specifies which of the baselines of the element snaps to the alignmentBaseline to determine the vertical position of the element on the line.
FlowElement
 InheritedfontFamily : String
[write-only] CharacterFormat: The name of the font to use, or a comma-separated list of font names.
FlowElement
 InheritedfontLookup : String
[write-only] CharacterFormat: Font lookup to use.
FlowElement
 InheritedfontSize : Object
[write-only] CharacterFormat: The size of the text in pixels.
FlowElement
 InheritedfontStyle : String
[write-only] CharacterFormat: Style of text.
FlowElement
 InheritedfontWeight : String
[write-only] CharacterFormat: Weight of text.
FlowElement
 Inheritedkerning : String
[write-only] CharacterFormat: Kerning adjusts the pixels between certain character pairs to improve readability.
FlowElement
 InheritedligatureLevel : String
[write-only] CharacterFormat: Controls which of the ligatures that are defined in the font may be used in the text.
FlowElement
 InheritedlineHeight : Object
[write-only] CharacterFormat: Leading controls for the text.
FlowElement
 InheritedlineThrough : Object
[write-only] CharacterFormat: Strikethrough.
FlowElement
 Inheritedlocale : String
[write-only] CharacterFormat: The locale of the text.
FlowElement
  mxmlChildren : Array
[write-only] Sets text based on content within span tags.
SpanElement
 Inheritedparent : FlowGroupElement
[read-only] Returns the parent of this FlowElement object.
FlowElement
 InheritedparentRelativeEnd : int
[read-only] Returns the relative end of this FlowElement object in the parent.
FlowElement
 InheritedparentRelativeStart : int
[read-only] Returns the relative start of this FlowElement object in the parent.
FlowElement
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
 InheritedrenderingMode : String
[write-only] CharacterFormat: The rendering mode used for this text.
FlowElement
  text : String
Receives the String of text that this SpanElement object holds.
SpanElement
 InheritedtextAlpha : Object
[write-only] CharacterFormat: Alpha (transparency) value for the text.
FlowElement
 InheritedtextDecoration : String
[write-only] CharacterFormat: Decoration on text.
FlowElement
 InheritedtextLength : int
[read-only] Returns the total length of text owned by this FlowElement object and its children.
FlowElement
 InheritedtextRotation : String
[write-only] CharacterFormat: Determines the amount of degrees to rotate this text.
FlowElement
 Inheritedtracking : Object
[write-only] Sets the tracking and is synonymous with the trackingRight property.
FlowElement
 InheritedtrackingLeft : Object
[write-only] CharacterFormat: Number in pixels (or percent of fontSize, like 120%) indicating the amount of tracking (manual kerning) to be applied to the left of each character.
FlowElement
 InheritedtrackingRight : Object
[write-only] CharacterFormat: Number in pixels (or percent of fontSize, like 120%) indicating the amount of tracking (manual kerning) to be applied to the right of each character.
FlowElement
 InheritedtypographicCase : String
[write-only] CharacterFormat: The type of typographic case used for this text.
FlowElement
 InheritedwhiteSpaceCollapse : String
[write-only] CharacterFormat: The setting used to collapse or preserve whitespace when importing text into a TextFlow.
FlowElement
Protected Properties
 PropertyDefined By
 InheritedeventMirror : EventDispatcher
[read-only] Gets the EventDispatcher associated with this FlowLeafElement.
FlowLeafElement
Public Methods
 MethodDefined By
  
Constructor - creates a SpanElement object to hold a run of text in a paragraph.
SpanElement
 Inherited
deepCopy(relativeStart:int = 0, relativeEnd:int = -1):FlowElement
Makes a deep copy of the portion of a FlowElement object between two character positions, including any children, and returns it as a FlowElement object.
FlowElement
 Inherited
Returns the start location of the element in the text flow as an absolute index.
FlowElement
 Inherited
Returns the ContainerFormattedElement that specifies its containers for filling.
FlowElement
 Inherited
Returns the character at the specified position, relative to this FlowElement object.
FlowElement
 Inherited
Returns the character code at the specified position, relative to this FlowElement.
FlowElement
 Inherited
Returns the FontMetrics object for the span's character format (CharacterFormat).
FlowLeafElement
 Inherited
Returns the start of this element relative to an ancestor element.
FlowElement
 Inherited
Returns the next FlowLeafElement object.
FlowLeafElement
 Inherited
Returns the next FlowElement sibling in the text flow hierarchy.
FlowElement
 Inherited
Returns the ParagraphElement object associated with this element.
FlowElement
 Inherited
Returns the previous FlowLeafElement object.
FlowLeafElement
 Inherited
Returns the previous FlowElement sibling in the text flow hierarchy.
FlowElement
 Inherited
Climbs the text flow hierarchy to return the root TextFlow object for the element.
FlowElement
 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
  
replaceText(relativeStartPosition:int, relativeEndPosition:int, textValue:String):void
Updates the text in text span based on the specified start and end positions.
SpanElement
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
shallowCopy(relativeStart:int = 0, relativeEnd:int = -1):FlowElement
Makes a copy of the content of this FlowElement object that occurs between two character positions.
FlowElement
  
splitAtPosition(relativePosition:int):SpanElement
Splits this SpanElement object at the specified position and returns a new SpanElement object for the content that follows the specified position.
SpanElement
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail
mxmlChildrenproperty
mxmlChildren:Array  [write-only]

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

Sets text based on content within span tags. This function is intended for use during mxml compiled import.



Implementation
    public function set mxmlChildren(value:Array):void

Throws
TypeError — if array element is not a SpecialCharacterElement or a String
textproperty 
text:String  [read-write]

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

Receives the String of text that this SpanElement object holds.

The text of a span does not include the carriage return (CR) at the end of the paragraph but it is included in the value of textLength .



Implementation
    public function get text():String
    public function set text(value:String):void
Constructor Detail
SpanElement()Constructor
public function SpanElement()

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

Constructor - creates a SpanElement object to hold a run of text in a paragraph.


Example

This example displays Hello World using the TextLayout component and two SpanElement objects.
  1. Add TextLayout to the library.
  2. Save this code as SpanElementExample.as in the same directory as your FLA.
  3. Set the Class in the Properties window of the FLA to SpanElementExample.
package {
    import flash.display.Sprite;
    import flash.text.engine.FontPosture;
    import flashx.textLayout.container.DisplayObjectContainerController;
    import flashx.textLayout.container.IContainerController;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
    import flashx.textLayout.elements.TextFlow;
    import flashx.textLayout.formats.CharacterFormat;
    import flashx.textLayout.edit.EditManager;

    public class SpanElementExample extends Sprite
    {
        public function SpanElementExample()
        {
            var textFlow:TextFlow = new TextFlow();
            var editManager:EditManager = new EditManager();
            var p:ParagraphElement = new ParagraphElement();
            var spanHello:SpanElement = new SpanElement();
            var spanWorld:SpanElement = new SpanElement();

            spanHello.text = "Hello, ";
            spanHello.fontSize = 48;
            spanWorld.text = "World!";
            spanWorld.fontSize = 56;
            spanWorld.fontStyle = FontPosture.ITALIC;

            p.addChild(spanHello);
            p.addChild(spanWorld);
            textFlow.interactionManager = editManager;
            textFlow.addChild(p);
            
            textFlow.flowComposer.addController(new DisplayObjectContainerController(this,400,200));
            textFlow.flowComposer.updateAllContainers();
        }
    }
}
Method Detail
replaceText()method
public function replaceText(relativeStartPosition:int, relativeEndPosition:int, textValue:String):void

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

Updates the text in text span based on the specified start and end positions. To insert text, set the end position equal to the start position. To append text to the existing text in the span, set the start position and the end position equal to the length of the existing text.

The replaced text includes the start character and up to but not including the end character.

Parameters

relativeStartPosition:int — The index position of the beginning of the text to be replaced, relative to the start of the span. The first character in the span is at position 0.
 
relativeEndPosition:int — The index one position after the last character of the text to be replaced, relative to the start of the span. Set this value equal to relativeStartPos for an insert.
 
textValue:String — The replacement text or the text to add, as the case may be.


Throws
RangeError — The relativeStartPosition or relativeEndPosition specified is out of range or a surrogate pair is being split as a result of the replace.
splitAtPosition()method 
public function splitAtPosition(relativePosition:int):SpanElement

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

Splits this SpanElement object at the specified position and returns a new SpanElement object for the content that follows the specified position.

This method throws an error if you attempt to split a surrogate pair. In Unicode UTF-16, a surrogate pair is a pair of 16-bit code units (a high code unit and a low code unit) that represent one of the abstract Unicode characters that cannot be represented in a single 16-bit word. The 16-bit high code unit is in the range of D800 to DBFF. The 16-bit low code unit is in the range of DC00 to DFFF.

Parameters

relativePosition:int — - relative position in the span to create the split

Returns
SpanElement — - the newly created span.

Throws
RangeError relativePosition is less than 0 or greater than textLength or a surrogate pair is being split.




 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/labs/textlayout/flashx/textLayout/elements/SpanElement.html