Packagenet.flashpunk.graphics
Classpublic class Text
InheritanceText Inheritance Image Inheritance Graphic Inheritance Object

Used for drawing text using embedded fonts. Note that users of Flex 3 must edit this class to get FlashPunk games to compile. The details of this can be found at the bottom of the file net/flashpunk/graphics/Text.as



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean = false
If the graphic should update.
Graphic
  align : String = left
[static] The alignment to assign to new Text objects.
Text
 Inheritedalpha : Number
Change the opacity of the Image, a value from 0 to 1.
Image
 Inheritedangle : Number = 0
Rotation of the image, in degrees.
Image
 Inheritedblend : String
Optional blend mode to use when drawing this image.
Image
 InheritedclipRect : Rectangle
[read-only] Clipping rectangle for the image.
Image
 Inheritedcolor : uint
The tinted color of the Image.
Image
  defaultLeading : Number = 0
[static] The leading to assign to new Text objects.
Text
 InheriteddrawMask : BitmapData
Set the transparency mask of the Image.
Image
 Inheritedflipped : Boolean
If you want to draw the Image horizontally flipped.
Image
  font : String = default
[static] The font to assign to new Text objects.
Text
  height : uint
[override] Height of the text image.
Text
  leading : Number
Leading (amount of vertical space between lines).
Text
 Inheritedlocked : Boolean
[read-only] True if the image is locked.
Image
 InheritedoriginX : Number = 0
X origin of the image, determines transformation point.
Image
 InheritedoriginY : Number = 0
Y origin of the image, determines transformation point.
Image
 Inheritedrelative : Boolean = true
If the graphic should render at its position relative to its parent Entity's position.
Graphic
  resizable : Boolean
If the text field can automatically resize if its contents grow.
Text
  resizable : Boolean = true
[static] The resizable property to assign to new Text objects.
Text
  richText : String
Rich-text string with markup.
Text
 Inheritedscale : Number = 1
Scale of the image, affects both x and y scale.
Image
  scaledHeight : Number
[override] The scaled height of the text.
Text
  scaledWidth : Number
[override] The scaled width of the text.
Text
 InheritedscaleX : Number = 1
X scale of the image.
Image
 InheritedscaleY : Number = 1
Y scale of the image.
Image
 InheritedscrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 InheritedscrollY : Number = 1
Y scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
  size : uint = 16
[static] The font size to assign to new Text objects.
Text
 Inheritedsmooth : Boolean
If the image should be drawn transformed with pixel smoothing.
Image
  text : String
Text string.
Text
  textHeight : uint
[read-only] Height of the text within the image.
Text
  textWidth : uint
[read-only] Width of the text within the image.
Text
 Inheritedtinting : Number
The amount the image will be tinted, suggested values from 0 to 1.
Image
 InheritedtintMode : Number
The tint mode - multiply or colorize.
Image
 Inheritedvisible : Boolean = true
If the graphic should render.
Graphic
  width : uint
[override] Width of the text image.
Text
  wordWrap : Boolean = false
[static] The wordWrap property to assign to new Text objects.
Text
 Inheritedx : Number = 0
X offset.
Graphic
 Inheritedy : Number = 0
Y offset.
Graphic
Protected Properties
 PropertyDefined By
  _align : String
Text
 Inherited_alpha : Number = 1
Image
 Inheritedassign : Function
Graphic
 Inherited_class : String
Image
 Inherited_color : uint = 0x00FFFFFF
Image
 Inherited_colorTransform : ColorTransform
Image
 Inherited_drawMask : BitmapData
Image
  _field : TextField
Text
 Inherited_flip : BitmapData
Image
 Inherited_flipped : Boolean
Image
 Inherited_flips : Object
[static]
Image
  _font : String
Text
  _form : TextFormat
Text
  _height : uint
Text
  _leading : Number
Text
 Inherited_matrix : Matrix
Image
  _richText : String
Text
  _size : uint
Text
 Inheritedsource : BitmapData
[read-only]
Image
  _styles : Object
Text
  _text : String
Text
  _textHeight : uint
Text
  _textWidth : uint
Text
 Inherited_tint : ColorTransform
Image
 Inherited_tintFactor : Number = 1.0
Image
 Inherited_tintMode : Number = 0.0
Image
  _width : uint
Text
  _wordWrap : Boolean
Text
Public Methods
 MethodDefined By
  
Text(text:String, x:Number = 0, y:Number = 0, options:Object = null, h:Number = 0)
Constructor.
Text
 Inherited
centerOO():void
Centers the Image's originX/Y to its center.
Image
 Inherited
Centers the Image's originX/Y to its center.
Image
 Inherited
clear():void
Clears the image buffer.
Image
 Inherited
createCircle(radius:uint, color:uint = 0xFFFFFF, alpha:Number = 1):Image
[static] Creates a new circle Image.
Image
 Inherited
createGradient(width:uint, height:uint, fromX:Number, fromY:Number, toX:Number, toY:Number, fromColor:uint, toColor:uint, fromAlpha:Number = 1, toAlpha:Number = 1):Image
[static] Creates a new gradient Image.
Image
 Inherited
createRect(width:uint, height:uint, color:uint = 0xFFFFFF, alpha:Number = 1):Image
[static] Creates a new rectangle Image.
Image
  
getTextProperty(name:String):*
Get TextField or TextForm property
Text
 Inherited
lock():void
Lock the image, preventing updateBuffer() from being run until unlock() is called, for performance.
Image
 Inherited
render(target:BitmapData, point:Point, camera:Point):void
Renders the graphic to the screen buffer.
Graphic
  
setStyle(tagName:String, params:*):void
Set the style for a subset of the text, for use with the richText property.
Text
  
setTextProperty(name:String, value:*):Boolean
Set TextField or TextFormat property returns true on success and false if property not found on either
Text
 Inherited
unlock():void
Unlock the image.
Image
 Inherited
update():void
Updates the graphic.
Graphic
 Inherited
updateBuffer(clearBefore:Boolean = false):void
Updates the image buffer.
Image
  
Updates the text buffer, which is the source for the image buffer.
Text
Protected Methods
 MethodDefined By
  
[override]
Text
Public Constants
 ConstantDefined By
 InheritedTINTING_COLORIZE : Number = 1.0
[static] tintMode value to tint in colorize mode.
Image
 InheritedTINTING_MULTIPLY : Number = 0.0
[static] tintMode value to tint in multiply mode.
Image
Property Detail
_alignproperty
protected var _align:String

_fieldproperty 
protected var _field:TextField

_fontproperty 
protected var _font:String

_formproperty 
protected var _form:TextFormat

_heightproperty 
protected var _height:uint

_leadingproperty 
protected var _leading:Number

_richTextproperty 
protected var _richText:String

_sizeproperty 
protected var _size:uint

_stylesproperty 
protected var _styles:Object

_textproperty 
protected var _text:String

_textHeightproperty 
protected var _textHeight:uint

_textWidthproperty 
protected var _textWidth:uint

_widthproperty 
protected var _width:uint

_wordWrapproperty 
protected var _wordWrap:Boolean

alignproperty 
align:String = left

The alignment to assign to new Text objects.


Implementation
    public static function get align():String
    public static function set align(value:String):void
defaultLeadingproperty 
public static var defaultLeading:Number = 0

The leading to assign to new Text objects.

fontproperty 
font:String = default

The font to assign to new Text objects.


Implementation
    public static function get font():String
    public static function set font(value:String):void
heightproperty 
height:uint[override]

Height of the text image.


Implementation
    public function get height():uint
    public function set height(value:uint):void
leadingproperty 
leading:Number

Leading (amount of vertical space between lines).


Implementation
    public function get leading():Number
    public function set leading(value:Number):void
resizableproperty 
public var resizable:Boolean

If the text field can automatically resize if its contents grow.

resizableproperty 
public static var resizable:Boolean = true

The resizable property to assign to new Text objects.

richTextproperty 
richText:String

Rich-text string with markup. Use setStyle() to control the appearance of marked-up text.


Implementation
    public function get richText():String
    public function set richText(value:String):void
scaledHeightproperty 
scaledHeight:Number[override]

The scaled height of the text.


Implementation
    public function get scaledHeight():Number
    public function set scaledHeight(value:Number):void
scaledWidthproperty 
scaledWidth:Number[override]

The scaled width of the text.


Implementation
    public function get scaledWidth():Number
    public function set scaledWidth(value:Number):void
sizeproperty 
size:uint = 16

The font size to assign to new Text objects.


Implementation
    public static function get size():uint
    public static function set size(value:uint):void
textproperty 
text:String

Text string.


Implementation
    public function get text():String
    public function set text(value:String):void
textHeightproperty 
textHeight:uint  [read-only]

Height of the text within the image.


Implementation
    public function get textHeight():uint
textWidthproperty 
textWidth:uint  [read-only]

Width of the text within the image.


Implementation
    public function get textWidth():uint
widthproperty 
width:uint[override]

Width of the text image.


Implementation
    public function get width():uint
    public function set width(value:uint):void
wordWrapproperty 
wordWrap:Boolean = false

The wordWrap property to assign to new Text objects.


Implementation
    public static function get wordWrap():Boolean
    public static function set wordWrap(value:Boolean):void
Constructor Detail
Text()Constructor
public function Text(text:String, x:Number = 0, y:Number = 0, options:Object = null, h:Number = 0)

Constructor.

Parameters
text:String — Text to display.
 
x:Number (default = 0) — X offset.
 
y:Number (default = 0) — Y offset.
 
options:Object (default = null) — An object containing key/value pairs of the following optional parameters: font Font family. size Font size. align Alignment ("left", "center" or "right"). wordWrap Automatic word wrapping. resizable If the text field can automatically resize if its contents grow. width Initial buffer width. height Initial buffer height. color Text color. alpha Text alpha. angle Rotation angle (see Image.angle). blend Blend mode (see Image.blend). visible Visibility (see Graphic.visible). scrollX See Graphic.scrollX. scrollY See Graphic.scrollY. relative See Graphic.relative. For backwards compatibility, if options is a Number, it will determine the initial buffer width.
 
h:Number (default = 0) — Deprecated. For backwards compatibility: if set and there is no options.height parameter set, will determine the initial buffer height.
Method Detail
getTextProperty()method
public function getTextProperty(name:String):*

Get TextField or TextForm property

Parameters

name:String

Returns
*
setStyle()method 
public function setStyle(tagName:String, params:*):void

Set the style for a subset of the text, for use with the richText property. Usage: text.setStyle("red", {color: 0xFF0000}); text.setStyle("big", {size: text.size}); text.richText = " ";

Parameters

tagName:String
 
params:*

setTextProperty()method 
public function setTextProperty(name:String, value:*):Boolean

Set TextField or TextFormat property returns true on success and false if property not found on either

Parameters

name:String
 
value:*

Returns
Boolean
updateColorTransform()method 
override protected function updateColorTransform():void

updateTextBuffer()method 
public function updateTextBuffer():void

Updates the text buffer, which is the source for the image buffer.