ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
spark.globalization 

StringTools  - AS3 Flex

Packagespark.globalization
Classpublic class StringTools
InheritanceStringTools Inheritance GlobalizationBase Inheritance AdvancedStyleClient Inheritance EventDispatcher Inheritance Object

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

The StringTools class provides locale-sensitve case conversion methods.

This class is a wrapper class around the flash.globalization.StringTools. Therefore, the case conversion functionality is provided by the flash.globalization.StringTools class. However, this StringTools class can be used in MXML declartions, uses the locale style for the requested Locale ID name, and has methods and properties that are bindable. Additionally, events are generated if there is an error or warning generated by the flash.globalization class.

The flash.globalization.StringTools class uses the underlying operating system for the case conversion functionality and on some operating systems, the flash.globalization classes are unsupported, this wrapper class provides fallback that makes use of the case conversion provided by the String class.

View the examples

More examples

Related API Elements



Public Properties
 PropertyDefined By
  actualLocaleIDName : String
[override] [read-only] The name of the actual locale ID used by this class object.
StringTools
 InheritedclassName : String
[read-only] The name of the component class.
AdvancedStyleClient
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedid : String
The identity of the component.
AdvancedStyleClient
 InheritedinheritingStyles : Object
An object containing the inheritable styles for this non-visual style client instance.
AdvancedStyleClient
  lastOperationStatus : String
[override] [read-only] The status of the most recent operation that this class object performed.
StringTools
 InheritedmoduleFactory : IFlexModuleFactory
A module factory is used as context for finding the style manager that controls the styles for this non-visual style client instance.
AdvancedStyleClient
 InheritednonInheritingStyles : Object
The beginning of this component's chain of non-inheriting styles.
AdvancedStyleClient
 InheritedstyleDeclaration : CSSStyleDeclaration
The style declaration that holds the inline styles declared by this object.
AdvancedStyleClient
 InheritedstyleManager : IStyleManager2
[read-only] Returns the StyleManager instance used by this component.
AdvancedStyleClient
 InheritedstyleName : Object
The source of this object's style values.
AdvancedStyleClient
 InheritedstyleParent : IAdvancedStyleClient
A component's parent is used to evaluate descendant selectors.
AdvancedStyleClient
Public Methods
 MethodDefined By
  
Constructs a new StringTools object that provides case conversion and other utilities according to the conventions of a given locale.
StringTools
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Deletes a style property from this component instance.
AdvancedStyleClient
 Inherited
Dispatches an event into the event flow.
EventDispatcher
  
[static] Lists all of the locale ID names supported by this class.
StringTools
 Inherited
Returns an Array of CSSStyleDeclaration objects for the type selector that applies to this component, or null if none exist.
AdvancedStyleClient
 Inherited
getStyle(styleProp:String):*
[override] Gets a style property that has been set anywhere in this component's style lookup chain.
GlobalizationBase
 Inherited
Returns true if currentCSSState is not null.
AdvancedStyleClient
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
The initialized method is called when this class or a class that extends this class is used in an MXML declaration.
AdvancedStyleClient
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Returns true if cssState matches currentCSSState.
AdvancedStyleClient
 Inherited
Determines whether this instance is the same as, or is a subclass of, the given type.
AdvancedStyleClient
 Inherited
Propagates style changes to the children of this style client instance.
AdvancedStyleClient
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets up the internal style cache values so that the getStyle() method functions.
AdvancedStyleClient
 Inherited
Registers the EffectManager as one of the event listeners for each effect event.
AdvancedStyleClient
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
setStyle(styleProp:String, newValue:*):void
Sets a style property on this component instance.
AdvancedStyleClient
 Inherited
Detects changes to style properties.
AdvancedStyleClient
 Inherited
Flex calls the stylesInitialized() method when the styles for a component are first initialized.
AdvancedStyleClient
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
  
Converts a string to lowercase according to language conventions.
StringTools
 Inherited
Returns the string representation of the specified object.
Object
  
Converts a string to uppercase according to language conventions.
StringTools
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 InheritedThe change event is generated whenever the locale style is changed or another property is set that would cause the format of a number to change or cause updates to the other values available through this class.GlobalizationBase
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
Styles

Styles are either common or associated with a specific theme. If the style is common, it can be used with any theme. If a style is associated with a specific theme, it can only be used if your application uses that theme.

Common Styles
 Style Description Defined By
 InheritedType: String CSS Inheritance: Yes
Language Version: ActionScript 3.0  Product Version: Flex 4.5  Runtime Versions: Flash10.1, AIR 2.5

The locale identifier that specifies the language, region, script and optionally other related tags and keys.
GlobalizationBase
Property Detail

actualLocaleIDName

property
actualLocaleIDName:String  [read-only] [override]

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

The name of the actual locale ID used by this class object. This is the locale that is used to access the formatting data and functionality from the operating system.

If the locale that was set by the locale style is not available, then the value of the actualLocaleIDName is different from the value of the locale style. It indicates the fallback locale that is being used. If the locale style was set to LocaleID.DEFAULT the name of the locale specified by the user's operating system is used.

This property can be used as the source for data binding. When this property is modified, it dispatches the change event.



Implementation
    override public function get actualLocaleIDName():String

Related API Elements

flash.globalization.StringTools.actualLocaleIDName
StringTools()

lastOperationStatus

property 
lastOperationStatus:String  [read-only] [override]

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

The status of the most recent operation that this class object performed. The lastOperationStatus is set whenever the constructor or a method of this class is called, or when a property is set. For the possible values see the description under each method.

This property can be used as the source for data binding. When this property is modified, it dispatches the change event.



Implementation
    override public function get lastOperationStatus():String
Constructor Detail

StringTools

()Constructor
public function StringTools()

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

Constructs a new StringTools object that provides case conversion and other utilities according to the conventions of a given locale. The locale for this class is supplied by the locale style. The locale style can be set in several ways:

  • Inheriting the style from a UIComponent by calling the UIComponent's addStyleClient method.
  • By using the class in an MXML declaration and inheriting the locale from the document that contains the declaration. Example:
          <fx:Declarations>
                 <s:StringTools id="st" />
          </fx:Declarations>
          
  • By using an MXML declaration and specifying the locale value in the list of assignments. Example:
          <fx:Declarations>
              <s:StringTools id="st_turkish" locale="tr-TR" />
          </fx:Declarations>
          
  • Calling the setStyle method, e.g. st.setStyle("locale", "tr-TR")

If the locale style is not set by one of the above techniques, the instance of this class will be added as a StyleClient to the topLevelApplication and will therefore inherit the locale style from the topLevelApplication object when the locale dependent property getter or locale dependent method is called.

Related API Elements

Method Detail

getAvailableLocaleIDNames

()method
public static function getAvailableLocaleIDNames():Vector.<String>

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

Lists all of the locale ID names supported by this class.

Returns
Vector.<String> — A vector of strings containing all of the locale ID names supported by this class and operating system.

toLowerCase

()method 
public function toLowerCase(s:String):String

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

Converts a string to lowercase according to language conventions. Depending on the locale, the output string length can differ from the input string length.

Parameters

s:StringString to convert to lowercase.

Returns
String — The converted lowercase string.

Related API Elements

toUpperCase

()method 
public function toUpperCase(s:String):String

Language Version: ActionScript 3.0
Product Version: Flex 4.5
Runtime Versions: Flash Player 10.1, AIR 2.5

Converts a string to uppercase according to language conventions. Depending on the locale, the output string length can differ from the input string length.

Parameters

s:StringString to convert to uppercase.

Returns
String — The converted uppercase string.

Related API Elements

StringToolsExample.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- Sample program for spark.globalization.StringTools -->
<s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Declarations>
        <s:StringTools id="stringTools" />
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            private static const localeList:ArrayCollection
                = new ArrayCollection([
                    { label:"Turkish (tr)", data:"tr" },
                    { label:"Greek (el)", data:"el" },
                    { label:"German (de)", data:"de" },
                    { label:"English (en)", data:"en" } ]);

            private static const inputString:String =
                "aá�æ� Iıİi (Turkish), σςΣΣ (Greek), SSß (German), bβв (Latin/Greek/Cyrillic)";
        ]]>
    </fx:Script>

    <mx:Form width="100%">
        <mx:FormItem label="Select Language">
            <mx:ComboBox id="localeSelector"
                change="setStyle('locale', localeSelector.selectedItem.data);"
                dataProvider="{localeList}"/>
        </mx:FormItem>
        <mx:FormItem label="Actual Locale ID Name">
            <mx:Text text="{stringTools.actualLocaleIDName}"/>
        </mx:FormItem>
        <mx:FormItem width="100%" label="Upper Case Result">
            <mx:Text width="100%"
                text="{stringTools.toUpperCase(inputString)}"/>
        </mx:FormItem>
        <mx:FormItem width="100%" label="Lower Case Result">
            <mx:Text width="100%"
                text="{stringTools.toLowerCase(inputString)}"/>
        </mx:FormItem>
    </mx:Form>
</s:Application>