Packageinfo.waterlijn.display
Classpublic class TextShape
InheritanceTextShape Inheritance flash.display.Sprite

The TextShape class.


Example
import info.waterlijn.display.*;
import flash.text.*;

var ts:TextShape = new TextShape();
addChild(ts);

var tf:TextFormat = new TextFormat('_sans', 12);
tf.align = TextFormatAlign.JUSTIFY;

ts.defaultTextFormat = tf;
ts.text = 'This is a text that will be placed inside the defined containers.';

ts.addContainer(TextShape.MULTI_POINT, [0, 0], [420, 0], [560, 70, 500, 140], [500, 210, 420, 280], [0, 280], [140, 210, 80, 140], [80, 70, 0, 0]);
ts.addContainer(TextShape.RECTANGLE, 80, 300, 450, 80);
ts.background = true;
ts.x = 10;
ts.y = 10;

ts.render();



Public Properties
 PropertyDefined by
  background : Boolean
TextShape
  backgroundColor : uint
TextShape
  defaultTextFormat : TextFormat
TextShape
  embedFonts : Boolean
TextShape
  htmlText : String
Sets a html text.
Supported html tags are <b></b> , <br>, <font color = '#000000'></font>, <i></i>, <p align = 'justify'></p>, <u></u> .
Changing font size using the font tag is supported but the line height for a rendered text is fixed and defined by the height of the first line of the text.
TextShape
  text : String
TextShape
  textColor : uint
TextShape
  textMargin : int = 2
Horizontal margin between a container and the text inside.
TextShape
Public Methods
 MethodDefined by
  
TextShape
  
addContainer(type:int, ... args):void
Adds a text container.
TextShape
  
removeAll():void
Removes all text containers.
TextShape
  
render():void
Renders the text.
TextShape
Public Constants
 ConstantDefined by
  ELLIPSE : int = 1
[static]
TextShape
  MULTI_POINT : int = 2
[static]
TextShape
  OBJECT : int = 3
[static]
TextShape
  RECTANGLE : int = 0
[static]
TextShape
Property detail
backgroundproperty
background:Boolean  [read-write]

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

Implementation
    public function get backgroundColor():uint
    public function set backgroundColor(value:uint):void
defaultTextFormatproperty 
defaultTextFormat:TextFormat  [read-write]

Implementation
    public function get defaultTextFormat():TextFormat
    public function set defaultTextFormat(value:TextFormat):void
embedFontsproperty 
embedFonts:Boolean  [read-write]

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

Sets a html text.
Supported html tags are <b></b> , <br>, <font color = '#000000'></font>, <i></i>, <p align = 'justify'></p>, <u></u> .
Changing font size using the font tag is supported but the line height for a rendered text is fixed and defined by the height of the first line of the text. This means if you use multiple font sizes, the first line should be the line with the largest line height.

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

Implementation
    public function get text():String
    public function set text(value:String):void
textColorproperty 
textColor:uint  [read-write]

Implementation
    public function get textColor():uint
    public function set textColor(value:uint):void
textMarginproperty 
public var textMargin:int = 2

Horizontal margin between a container and the text inside.

Constructor detail
TextShape()constructor
public function TextShape()
Method detail
addContainer()method
public function addContainer(type:int, ... args):void

Adds a text container.

Parameters
type:int — the container type ( TextShape.RECTANGLE, TextShape.ELLIPSE or TextShape.MULTI_POINT ).
 
... args — the arguments required for the selected container type.
  • myTextShape.addContainer(TextShape.RECTANGLE, x, y, width, height);
  • myTextShape.addContainer(TextShape.ELLIPSE, x, y, width, height);
  • myTextShape.addContainer(TextShape.MULTI_POINT, [x1, y1], [cx2, cy2, ax2, ay2], [x3, y3] );
  • myTextShape.addContainer(TextShape.OBJECT, myContainerMovieClip );
  • myTextShape.addContainer(TextShape.OBJECT, x, y, myContainerMovieClip );
In case of a MULTI_POINT container, the first coordinates are the start coordinates. The other coordinates are connected with a line (2 numbers) or a curve (4 numbers).
In case of an OBJECT container, the object will be removed from where it was on the display list if it was on that list.
removeAll()method 
public function removeAll():void

Removes all text containers.

render()method 
public function render():void

Renders the text.

Constant detail
ELLIPSEconstant
public static const ELLIPSE:int = 1
MULTI_POINTconstant 
public static const MULTI_POINT:int = 2
OBJECTconstant 
public static const OBJECT:int = 3
RECTANGLEconstant 
public static const RECTANGLE:int = 0