Package | starling.text |
Class | public class TextFormat |
Inheritance | TextFormat EventDispatcher Object |
Note that not all properties are used by all font renderers: bitmap fonts ignore the "bold", "italic", and "underline" values.
Property | Defined By | ||
---|---|---|---|
bold : Boolean Indicates whether the text is bold. | TextFormat | ||
color : uint The color of the text. | TextFormat | ||
font : String The name of the font. | TextFormat | ||
horizontalAlign : String The horizontal alignment of the text. | TextFormat | ||
italic : Boolean Indicates whether the text is italicized. | TextFormat | ||
kerning : Boolean Indicates whether kerning is enabled. | TextFormat | ||
leading : Number The amount of vertical space (called 'leading') between lines. | TextFormat | ||
size : Number The size of the font. | TextFormat | ||
underline : Boolean Indicates whether the text is underlined. | TextFormat | ||
verticalAlign : String The vertical alignment of the text. | TextFormat |
Method | Defined By | ||
---|---|---|---|
TextFormat(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center) Creates a new TextFormat instance with the given properties. | TextFormat | ||
addEventListener(type:String, listener:Function):void Registers an event listener at a certain object. | EventDispatcher | ||
Creates a clone of this instance. | TextFormat | ||
copyFrom(format:TextFormat):void Copies all properties from another TextFormat instance. | TextFormat | ||
dispatchEvent(event:Event):void Dispatches an event to all objects that have registered listeners for its type. | EventDispatcher | ||
dispatchEventWith(type:String, bubbles:Boolean = false, data:Object = null):void Dispatches an event with the given parameters to all objects that have registered
listeners for the given type. | EventDispatcher | ||
hasEventListener(type:String, listener:Function = null):Boolean If called with one argument, figures out if there are any listeners registered for
the given event type. | EventDispatcher | ||
removeEventListener(type:String, listener:Function):void Removes an event listener from the object. | EventDispatcher | ||
removeEventListeners(type:String = null):void Removes all event listeners with a certain type, or all of them if type is null. | EventDispatcher | ||
setTo(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center):void Sets the most common properties at once. | TextFormat | ||
toNativeFormat(out:TextFormat = null):TextFormat Converts the Starling TextFormat instance to a Flash TextFormat. | TextFormat |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when any property of the instance changes. | TextFormat |
bold | property |
bold:Boolean
Indicates whether the text is bold.
The default value is false
.
public function get bold():Boolean
public function set bold(value:Boolean):void
color | property |
color:uint
The color of the text. Note that bitmap fonts should be exported in plain white so
that tinting works correctly. If your bitmap font contains colors, set this property
to Color.WHITE
to get the desired result.
The default value is black
.
public function get color():uint
public function set color(value:uint):void
font | property |
font:String
The name of the font. TrueType fonts will be looked up from embedded fonts and
system fonts; bitmap fonts must be registered at the TextField class first.
Beware: If you loaded an embedded font at runtime, you must call
TextField.updateEmbeddedFonts()
for Starling to recognize it.
public function get font():String
public function set font(value:String):void
horizontalAlign | property |
horizontalAlign:String
The horizontal alignment of the text.
The default value is center
.
public function get horizontalAlign():String
public function set horizontalAlign(value:String):void
See also
italic | property |
italic:Boolean
Indicates whether the text is italicized.
The default value is false
.
public function get italic():Boolean
public function set italic(value:Boolean):void
kerning | property |
kerning:Boolean
Indicates whether kerning is enabled. Kerning adjusts the pixels between certain character pairs to improve readability.
The default value is true
.
public function get kerning():Boolean
public function set kerning(value:Boolean):void
leading | property |
leading:Number
The amount of vertical space (called 'leading') between lines.
The default value is 0
.
public function get leading():Number
public function set leading(value:Number):void
size | property |
size:Number
The size of the font. For bitmap fonts, use BitmapFont.NATIVE_SIZE
for
the original size.
public function get size():Number
public function set size(value:Number):void
underline | property |
underline:Boolean
Indicates whether the text is underlined.
The default value is false
.
public function get underline():Boolean
public function set underline(value:Boolean):void
verticalAlign | property |
verticalAlign:String
The vertical alignment of the text.
The default value is center
.
public function get verticalAlign():String
public function set verticalAlign(value:String):void
See also
TextFormat | () | Constructor |
public function TextFormat(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center)
Creates a new TextFormat instance with the given properties.
Parametersfont:String (default = Verdana )
| |
size:Number (default = 12 )
| |
color:uint (default = 0x0 )
| |
horizontalAlign:String (default = center )
| |
verticalAlign:String (default = center )
|
clone | () | method |
copyFrom | () | method |
public function copyFrom(format:TextFormat):void
Copies all properties from another TextFormat instance.
Parameters
format:TextFormat |
setTo | () | method |
public function setTo(font:String = Verdana, size:Number = 12, color:uint = 0x0, horizontalAlign:String = center, verticalAlign:String = center):void
Sets the most common properties at once.
Parameters
font:String (default = Verdana )
| |
size:Number (default = 12 )
| |
color:uint (default = 0x0 )
| |
horizontalAlign:String (default = center )
| |
verticalAlign:String (default = center )
|
toNativeFormat | () | method |
public function toNativeFormat(out:TextFormat = null):TextFormat
Converts the Starling TextFormat instance to a Flash TextFormat.
Parameters
out:TextFormat (default = null )
|
TextFormat |
change | Event |