Packagecom.esri.ags.symbol
Classpublic class TextSymbol
InheritanceTextSymbol Inheritance Symbol Inheritance flash.events.EventDispatcher

Used to display text at points on the graphics layer. Use the flash textformat to change font, size, bold, italic, underline and other format properties.

The actual text can be set using the following properties: htmlText, text, textAttribute or textFunction.

Note: Changing alpha and angle only works with embedded fonts.

Default MXML PropertytextFormat


Example
MXML usage of TextFormat inside TextSymbol:
 <esri:TextSymbol id="ts1" text="Verdana with color" placement="middle">
     <flash:TextFormat font="Verdana" color="0xFF00FF" bold="true" underline="true"/>
 </esri:TextSymbol>

MXML usage of TextSymbol with bindable textFormat:
 <flash:TextFormat id="ftf" font="Verdana" color="0xFF00FF" bold="true" underline="true"/>
 <esri:TextSymbol id="ts2" text="Same Verdana" textFormat="{ftf}"/>

MXML usage of TextSymbol using an embedded font:
 <mx:Style>
      @font-face {
          src:url("assets/esri_1.ttf");
          fontFamily: myEmbeddedFont;
          unicodeRange:
              U+0041-U+005A,
              U+0061-U+007A,
              U+0030-U+0039,
      }
 </mx:Style>
 <esri:TextSymbol id="ts_esrifont" text="hH Q">
     <flash:TextFormat color="0x0000FF" font="myEmbeddedFont" alpha="0.5"/>
 </esri:TextSymbol>

ActionScript usage of TextSymbol:
 var ts4:TextSymbol = new TextSymbol("Some text", null, 0x0000FF);

See also

Live sample - Marker Symbols
Live sample - Change Text Symbols on-the-fly


Public Properties
 PropertyDefined by
  alpha : Number
The text alpha (transparency).
TextSymbol
  angle : Number
The angle of the TextSymbol.
TextSymbol
  background : Boolean
Specifies whether the text field has a background fill.
TextSymbol
  backgroundColor : uint
The background color of the text field.
TextSymbol
  border : Boolean
Specifies whether the text field has a border.
TextSymbol
  borderColor : uint
The color of the text field border.
TextSymbol
  color : uint
The text color (if not set with flash:TextFormat).
TextSymbol
  htmlText : String
Contains the HTML representation of the text field's contents.
TextSymbol
  placement : String
The text placement.
TextSymbol
  text : String
The text string to display.
TextSymbol
  textAttribute : String
The string representing the attribute of the graphic that should populate the "text" content.
TextSymbol
  textFormat : TextFormat
The text formatting to use for displaying the text.
TextSymbol
  textFunction : Function
The text function allows for the text of the text symbol to be dynamically picked - for example based on attributes or position of the graphic.
TextSymbol
  xoffset : Number
The X offset value in pixels.
TextSymbol
  yoffset : Number
The Y offset value in pixels.
TextSymbol
Public Methods
 MethodDefined by
  
TextSymbol(text:String = null, htmlText:String = null, color:uint = 0x000000, border:Boolean = false, borderColor:uint = 0x000000, background:Boolean = false, backgroundColor:uint = 0xFFFFFF, placement:String = "middle", angle:Number = 0, xoffset:Number = 0, yoffset:Number = 0, textFormat:TextFormat = null, textAttribute:String = null, textFunction:Function = null)
Creates a new TextSymbol.
TextSymbol
 Inherited
clear(sprite:Sprite):void
Clears the graphics that were drawn to the sprite object.
Symbol
 Inherited
destroy(sprite:Sprite):void
Removes all the graphics that were drawn to the sprite object and resets its properties.
Symbol
 Inherited
draw(sprite:Sprite, geometry:Geometry, attributes:Object, map:Map):void
Draw the graphics on the sprite object.
Symbol
Protected Methods
 MethodDefined by
 Inherited
Helper function to dispatch a change event.
Symbol
 Inherited
removeAllChildren(sprite:Sprite):void
Removes all children from the sprite object.
Symbol
 Inherited
toScreenX(map:Map, mapX:Number):Number
Converts the x-coordinate of map point to a screen point.
Symbol
 Inherited
toScreenY(map:Map, mapY:Number):Number
Converts the y-coordinate of map point to a screen point.
Symbol
Public Constants
 ConstantDefined by
  PLACEMENT_ABOVE : String = "above"
[static] Places the label above the point.
TextSymbol
  PLACEMENT_BELOW : String = "below"
[static] Places the label below the point.
TextSymbol
  PLACEMENT_END : String = "end"
[static] Places the label so that the text ends at the point, that is, places the label to the left of the point.
TextSymbol
  PLACEMENT_MIDDLE : String = "middle"
[static] Places the label centered on the point.
TextSymbol
  PLACEMENT_START : String = "start"
[static] Places the label so that the text starts at the point, that is, places the label to the right of the point.
TextSymbol
Property detail
alphaproperty
alpha:Number  [read-write]

The text alpha (transparency). Possible values range from 0.0 (invisible, fully transparent) to 1.0 (opaque, fully visible).

The default value is 1.0 (opaque, fully visible).

This property can be used as the source for data binding.

Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
angleproperty 
angle:Number  [read-write]

The angle of the TextSymbol.

The default value is 0.

This property can be used as the source for data binding.

Implementation
    public function get angle():Number
    public function set angle(value:Number):void
backgroundproperty 
background:Boolean  [read-write]

Specifies whether the text field has a background fill. If true, the text field has a background fill. If false, the text field has no background fill.

The default value is false.

This property can be used as the source for data binding.

Implementation
    public function get background():Boolean
    public function set background(value:Boolean):void
backgroundColorproperty 
backgroundColor:uint  [read-write]

The background color of the text field. This property can be retrieved or set, even if there currently is no background, but the color is visible only if the text field has the background property set to true.

The default value is 0xFFFFFF (white).

This property can be used as the source for data binding.

Implementation
    public function get backgroundColor():uint
    public function set backgroundColor(value:uint):void
borderproperty 
border:Boolean  [read-write]

Specifies whether the text field has a border. If true, the text field has a border. If false, the text field has no border.

The default value is false.

This property can be used as the source for data binding.

Implementation
    public function get border():Boolean
    public function set border(value:Boolean):void
borderColorproperty 
borderColor:uint  [read-write]

The color of the text field border. This property can be retrieved or set, even if there currently is no border, but the color is visible only if the text field has the border property set to true.

The default value is 0x000000 (black).

This property can be used as the source for data binding.

Implementation
    public function get borderColor():uint
    public function set borderColor(value:uint):void
colorproperty 
color:uint  [read-write]

The text color (if not set with flash:TextFormat). Setting the color on flash:TextFormat (see sample at top) will overwrite the color set here.

The default value is 0x000000 (black).

This property can be used as the source for data binding.

Implementation
    public function get color():uint
    public function set color(value:uint):void
htmlTextproperty 
htmlText:String  [read-write]

Contains the HTML representation of the text field's contents. When you use the htmlText property, you use a subset of HTML that is supported by Flash Player and AIR, which support the following tags:

This property can be used as the source for data binding.

Implementation
    public function get htmlText():String
    public function set htmlText(value:String):void

See also

placementproperty 
placement:String  [read-write]

The text placement.

The default value is PLACEMENT_MIDDLE.

This property can be used as the source for data binding.

Implementation
    public function get placement():String
    public function set placement(value:String):void
textproperty 
text:String  [read-write]

The text string to display.

This property can be used as the source for data binding.

Implementation
    public function get text():String
    public function set text(value:String):void
textAttributeproperty 
textAttribute:String  [read-write]

The string representing the attribute of the graphic that should populate the "text" content.

This property can be used as the source for data binding.

Implementation
    public function get textAttribute():String
    public function set textAttribute(value:String):void
textFormatproperty 
textFormat:TextFormat  [read-write]

The text formatting to use for displaying the text.

This property can be used as the source for data binding.

Implementation
    public function get textFormat():TextFormat
    public function set textFormat(value:TextFormat):void

See also

textFunctionproperty 
textFunction:Function  [read-write]

The text function allows for the text of the text symbol to be dynamically picked - for example based on attributes or position of the graphic. This will be used when text symbol does not have its own text property set. The function should have the following signature: public function myTextFunction(point : MapPoint, attributes:Object):String

This property can be used as the source for data binding.

Implementation
    public function get textFunction():Function
    public function set textFunction(value:Function):void
xoffsetproperty 
xoffset:Number  [read-write]

The X offset value in pixels.

This property can be used as the source for data binding.

Implementation
    public function get xoffset():Number
    public function set xoffset(value:Number):void
yoffsetproperty 
yoffset:Number  [read-write]

The Y offset value in pixels.

This property can be used as the source for data binding.

Implementation
    public function get yoffset():Number
    public function set yoffset(value:Number):void
Constructor detail
TextSymbol()constructor
public function TextSymbol(text:String = null, htmlText:String = null, color:uint = 0x000000, border:Boolean = false, borderColor:uint = 0x000000, background:Boolean = false, backgroundColor:uint = 0xFFFFFF, placement:String = "middle", angle:Number = 0, xoffset:Number = 0, yoffset:Number = 0, textFormat:TextFormat = null, textAttribute:String = null, textFunction:Function = null)

Creates a new TextSymbol. The actual text can be through either 'htmlText', 'text', 'textAttribute' or 'textFunction'. If you set more than one of them, 'htmlText' will take precedence over 'text' which takes precedence over 'textAttribute', which takes precedence over 'textFunction'.

Parameters
text:String (default = null) — The actual text in the TextSymbol.
 
htmlText:String (default = null) — Contains the HTML representation of the text field's contents.
 
color:uint (default = 0x000000) — The color (in RGB) of the text in the TextSymbol.
 
border:Boolean (default = false) — Specifies whether the text symbol has a border.
 
borderColor:uint (default = 0x000000) — The border color of the text field in the TextSymbol.
 
background:Boolean (default = false) — Specifies whether the text symbol has a background fill.
 
backgroundColor:uint (default = 0xFFFFFF) — The background color of the text field in the TextSymbol.
 
placement:String (default = "middle") — Specifies the position of the text w.r.t the point.
 
angle:Number (default = 0) — The angle (rotation) of the text in the TextSymbol.
 
xoffset:Number (default = 0) — The X offset value in pixels.
 
yoffset:Number (default = 0) — The Y offset value in pixels.
 
textFormat:TextFormat (default = null) — The text formatting to use for displaying the text.
 
textAttribute:String (default = null) — The string representing the attribute of the graphic that should populate the "text" content [added in version 1.2].
 
textFunction:Function (default = null) — The text function to populate the "text" content [added in version 1.2].
Constant detail
PLACEMENT_ABOVEconstant
public static const PLACEMENT_ABOVE:String = "above"

Places the label above the point.

PLACEMENT_BELOWconstant 
public static const PLACEMENT_BELOW:String = "below"

Places the label below the point.

PLACEMENT_ENDconstant 
public static const PLACEMENT_END:String = "end"

Places the label so that the text ends at the point, that is, places the label to the left of the point.

PLACEMENT_MIDDLEconstant 
public static const PLACEMENT_MIDDLE:String = "middle"

Places the label centered on the point.

PLACEMENT_STARTconstant 
public static const PLACEMENT_START:String = "start"

Places the label so that the text starts at the point, that is, places the label to the right of the point.