| Package | com.soma.view |
| Class | public class SomaText |
| Inheritance | SomaText 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
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");
var myText:SomaText = new SomaText("text with style from the global stylesheet", "simpleStyle");
var myText:SomaText = new SomaText("text with style from another stylesheet", "simpleStyle", _customStylesheet);
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;
myText.setProperties({width: 220, multiline: true, wordWrap: true, selectable: true});
var myText:SomaText = new SomaText("multiline text with textfield properties set in the stylesheet: width, multiline, word-wrap, selectable, and so on.", "defaultTextMultiline");
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");
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;
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
| Property | Defined 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 | ||
| Method | Defined 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 | ||
|
resetToDefault():void
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 | ||
| DEFAULT_ANTIALIAS | property |
public static var DEFAULT_ANTIALIAS:String = "advanced"Default alias that will be used for each new instance created (AntiAliasType), default is "advanced".
| DEFAULT_AUTOSIZE | property |
public static var DEFAULT_AUTOSIZE:String = "left"Default autosize that will be used for each new instance created (TextFieldAutoSize), default is "left".
| DEFAULT_CONDENSE_WHITE | property |
public static var DEFAULT_CONDENSE_WHITE:Boolean = trueDefault condenseWhite value that will be used for each new instance created, default is "true".
| DEFAULT_DOUBLECLICK_ENABLED | property |
public static var DEFAULT_DOUBLECLICK_ENABLED:Boolean = falseDefault doubleClickEnabled value that will be used for each new instance created, default is "false".
| DEFAULT_EMBED_FONT | property |
public static var DEFAULT_EMBED_FONT:Boolean = falseDefault font embedded value that will be used for each new instance created, default is "false".
| DEFAULT_GRIDFITTYPE | property |
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_ENABLED | property |
public static var DEFAULT_MOUSEWHEEL_ENABLED:Boolean = falseDefault mouseWheelEnabled value that will be used for each new instance created, default is "false".
| DEFAULT_MULTILINE | property |
public static var DEFAULT_MULTILINE:Boolean = falseDefault multiline value that will be used for each new instance created, default is "false".
| DEFAULT_RICHTEXT_CLIPBOARD_ENABLED | property |
public static var DEFAULT_RICHTEXT_CLIPBOARD_ENABLED:Boolean = trueDefault useRichTextClipboard value that will be used for each new instance created, default is "true".
| DEFAULT_SELECTABLE | property |
public static var DEFAULT_SELECTABLE:Boolean = falseDefault selectable value that will be used for each new instance created, default is "false".
| DEFAULT_TYPE | property |
public static var DEFAULT_TYPE:String = "dynamic"Default type that will be used for each new instance created (TextFieldType), default is "dynamic".
| DEFAULT_WORDWRAP | property |
public static var DEFAULT_WORDWRAP:Boolean = falseDefault wordWrap value that will be used for each new instance created, default is "false".
| multiline | property |
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
| style | property |
style:String [read-only]Get the style applied to the TextField.
Implementation public function get style():String
| type | property |
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.
public function set type(value:String):void
| SomaText | () | constructor |
public function SomaText(value:String = "", style:String = null, properties:Object = null, stylesheet:StyleSheet = null)Creates a new instance of the SomaText class.
Parametersvalue: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).
|
| info | () | method |
public function info():StringDisplay information about the textfield and the styles used.
trace(somaTextInstance.info());
String — A String.
|
| resetToDefault | () | method |
public function resetToDefault():voidRemove 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):voidShortcut to set TextField properties, example: somatext.setProperties({multiline: true, selectable: true});
Parametersproperties:Object — Object of TextField properties.
|
| setStyle | () | method |
public function setStyle(style:String, stylesheet:StyleSheet = null):voidSet a style from a stylesheet (no dot), example: somatext.setStyle("myStyle").
Parametersstyle:String — style name from a stylesheet .
|
|
stylesheet:StyleSheet (default = null) — stylesheet of the style. If none is passed, the global stylesheet will be used.
|