Packagecom.soma.view
Classpublic class SomaText
InheritanceSomaText Inheritance flash.text.TextField

Author: Romuald Quantin - www.soundstep.com

Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0

Copyright:

The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.

The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.

Usage:
SomaText is extending the TextField class and add a powerful Stylesheet Management with parsable properties.
You can find a full list of CSS properties you can use with SomaText in the Soma Protest CSS properties page.

SomaText will use the global stylesheet if you are passing a style without passing a stylesheet (see Soma and StyleManager to set a global stylesheet).

You can see the Soma Protest CSS file for a stylesheet example. Simple text

var myText:SomaText = new SomaText("simple text");
  
Text with style from the global stylesheet
var myText:SomaText = new SomaText("text with style from the global stylesheet", "simpleStyle");
  
Text with style from another stylesheet
var myText:SomaText = new SomaText("text with style from another stylesheet", "simpleStyle", _customStylesheet);
  
Multiline text with properties set in actionscript
var myText:SomaText = new SomaText("multiline text with textfield properties modified in the actionscript: width, multiline, wordWrap, selectable, and so on.", "defaultText");
myText.width = 220;
myText.multiline = true;
myText.wordWrap = true;
myText.selectable = true;
  
Can be set in the constructor or using the setProperties method
myText.setProperties({width: 220, multiline: true, wordWrap: true, selectable: true});
  
Multiline text with properties set in the stylesheet
var myText:SomaText = new SomaText("multiline text with textfield properties set in the stylesheet: width, multiline, word-wrap, selectable, and so on.", "defaultTextMultiline");
  
Multiline html text
var s1:String = '<p>paragraph 1, <b>multiline html text</b> with <i>more style</i> in the <span class="color1">same SomaText</span> instance.</p>';
var s2:String = '<p class="para">paragraph 2, <b>multiline html text</b> with <i>more style</i> in the <span class="color1">same SomaText</span> instance.</p>';
var myText:SomaText = new SomaText(s1 + s2, "defaultTextMultiline");
  
Text input
var myText:SomaText = new SomaText("text input", "defaultTextMultiline");
myText.type = TextFieldType.INPUT;
myText.autoSize = TextFieldAutoSize.NONE;
myText.width = 220;
myText.height = 20;
myText.background = true;
myText.backgroundColor = 0xFFFFFF;
  
Text with link
var myText:SomaText = new SomaText('text with <a href="http://www.soundstep.com/somaprotest/www/#/stylesheet/" target="_blank">link and hover</a>', "defaultText");
  

See also

Soma
PageEvent


Public Properties
 PropertyDefined by
  DEFAULT_ANTIALIAS : String = "advanced"
[static] Default alias that will be used for each new instance created (AntiAliasType), default is "advanced".
SomaText
  DEFAULT_AUTOSIZE : String = "left"
[static] Default autosize that will be used for each new instance created (TextFieldAutoSize), default is "left".
SomaText
  DEFAULT_CONDENSE_WHITE : Boolean = true
[static] Default condenseWhite value that will be used for each new instance created, default is "true".
SomaText
  DEFAULT_DOUBLECLICK_ENABLED : Boolean = false
[static] Default doubleClickEnabled value that will be used for each new instance created, default is "false".
SomaText
  DEFAULT_EMBED_FONT : Boolean = false
[static] Default font embedded value that will be used for each new instance created, default is "false".
SomaText
  DEFAULT_GRIDFITTYPE : String = "none"
[static] Default gridFitType value that will be used for each new instance created (GridFitType), default is "none".
SomaText
  DEFAULT_MOUSEWHEEL_ENABLED : Boolean = false
[static] Default mouseWheelEnabled value that will be used for each new instance created, default is "false".
SomaText
  DEFAULT_MULTILINE : Boolean = false
[static] Default multiline value that will be used for each new instance created, default is "false".
SomaText
  DEFAULT_RICHTEXT_CLIPBOARD_ENABLED : Boolean = true
[static] Default useRichTextClipboard value that will be used for each new instance created, default is "true".
SomaText
  DEFAULT_SELECTABLE : Boolean = false
[static] Default selectable value that will be used for each new instance created, default is "false".
SomaText
  DEFAULT_TYPE : String = "dynamic"
[static] Default type that will be used for each new instance created (TextFieldType), default is "dynamic".
SomaText
  DEFAULT_WORDWRAP : Boolean = false
[static] Default wordWrap value that will be used for each new instance created, default is "false".
SomaText
  multiline : Boolean
[write-only] Indicates whether the text field is a multiline text field.
SomaText
  style : String
[read-only] Get the style applied to the TextField.
SomaText
  type : String
[write-only] The type of the text field.
SomaText
Public Methods
 MethodDefined by
  
SomaText(value:String = "", style:String = null, properties:Object = null, stylesheet:StyleSheet = null)
Creates a new instance of the SomaText class.
SomaText
  
info():String
Display information about the textfield and the styles used.
SomaText
  
Remove styles and stylesheet from a TextField to show the default values and/or set new styles and stylesheet.
SomaText
  
setProperties(properties:Object):void
Shortcut to set TextField properties, example: somatext.setProperties({multiline: true, selectable: true});
SomaText
  
setStyle(style:String, stylesheet:StyleSheet = null):void
Set a style from a stylesheet (no dot), example: somatext.setStyle("myStyle").
SomaText
Property detail
DEFAULT_ANTIALIASproperty
public static var DEFAULT_ANTIALIAS:String = "advanced"

Default alias that will be used for each new instance created (AntiAliasType), default is "advanced".

DEFAULT_AUTOSIZEproperty 
public static var DEFAULT_AUTOSIZE:String = "left"

Default autosize that will be used for each new instance created (TextFieldAutoSize), default is "left".

DEFAULT_CONDENSE_WHITEproperty 
public static var DEFAULT_CONDENSE_WHITE:Boolean = true

Default condenseWhite value that will be used for each new instance created, default is "true".

DEFAULT_DOUBLECLICK_ENABLEDproperty 
public static var DEFAULT_DOUBLECLICK_ENABLED:Boolean = false

Default doubleClickEnabled value that will be used for each new instance created, default is "false".

DEFAULT_EMBED_FONTproperty 
public static var DEFAULT_EMBED_FONT:Boolean = false

Default font embedded value that will be used for each new instance created, default is "false".

DEFAULT_GRIDFITTYPEproperty 
public static var DEFAULT_GRIDFITTYPE:String = "none"

Default gridFitType value that will be used for each new instance created (GridFitType), default is "none".

DEFAULT_MOUSEWHEEL_ENABLEDproperty 
public static var DEFAULT_MOUSEWHEEL_ENABLED:Boolean = false

Default mouseWheelEnabled value that will be used for each new instance created, default is "false".

DEFAULT_MULTILINEproperty 
public static var DEFAULT_MULTILINE:Boolean = false

Default multiline value that will be used for each new instance created, default is "false".

DEFAULT_RICHTEXT_CLIPBOARD_ENABLEDproperty 
public static var DEFAULT_RICHTEXT_CLIPBOARD_ENABLED:Boolean = true

Default useRichTextClipboard value that will be used for each new instance created, default is "true".

DEFAULT_SELECTABLEproperty 
public static var DEFAULT_SELECTABLE:Boolean = false

Default selectable value that will be used for each new instance created, default is "false".

DEFAULT_TYPEproperty 
public static var DEFAULT_TYPE:String = "dynamic"

Default type that will be used for each new instance created (TextFieldType), default is "dynamic".

DEFAULT_WORDWRAPproperty 
public static var DEFAULT_WORDWRAP:Boolean = false

Default wordWrap value that will be used for each new instance created, default is "false".

multilineproperty 
multiline:Boolean  [write-only]

Indicates whether the text field is a multiline text field. If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field.

Implementation
    public function set multiline(value:Boolean):void
styleproperty 
style:String  [read-only]

Get the style applied to the TextField.

Implementation
    public function get style():String
typeproperty 
type:String  [write-only]

The type of the text field. Either one of the following TextFieldType constants: TextFieldType.DYNAMIC, which specifies a dynamic text field, which a user cannot edit, or TextFieldType.INPUT, which specifies an input text field, which a user can edit.

Implementation
    public function set type(value:String):void
Constructor detail
SomaText()constructor
public function SomaText(value:String = "", style:String = null, properties:Object = null, stylesheet:StyleSheet = null)

Creates a new instance of the SomaText class.

Parameters
value:String (default = "") — text or htmlText value.
 
style:String (default = null) — of a stylesheet (without dot), you must have a global stylesheet registered (see StyleManager) or pass a stylesheet in the fourth parameter.
 
properties:Object (default = null) — object of properties, shortcut to set properties to the TextField, example: {multiline: true, selectable: true}.
 
stylesheet:StyleSheet (default = null) — StyleSheet target for the styles used (the global stylesheet will be used if you dont pass any).
Method detail
info()method
public function info():String

Display information about the textfield and the styles used.

   trace(somaTextInstance.info());
   

Returns
String — A String.
resetToDefault()method 
public function resetToDefault():void

Remove styles and stylesheet from a TextField to show the default values and/or set new styles and stylesheet.

setProperties()method 
public function setProperties(properties:Object):void

Shortcut to set TextField properties, example: somatext.setProperties({multiline: true, selectable: true});

Parameters
properties:Object — Object of TextField properties.
setStyle()method 
public function setStyle(style:String, stylesheet:StyleSheet = null):void

Set a style from a stylesheet (no dot), example: somatext.setStyle("myStyle").

Parameters
style:String — style name from a stylesheet .
 
stylesheet:StyleSheet (default = null) — stylesheet of the style. If none is passed, the global stylesheet will be used.