Справочник по ActionScript® 3.0 для платформы Adobe® Flash®
Домашняя страница  |  Скрыть список пакетов и классов |  Пакеты  |  Классы  |  Что нового  |  Указатель  |  Приложения  |  Почему по-английски?
Фильтры: Получение данных с сервера...
Получение данных с сервера...
com.adobe.gravity.utility.message 

FormatMessage  - AS3 ADEP Client Component

Пакетcom.adobe.gravity.utility.message
Классpublic class FormatMessage
НаследованиеFormatMessage Inheritance Object

Язык версии: ActionScript 3.0
Версия продукта: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Версии среды выполнения: AIR 1.1, Flash Player 9

FormatMessage is a utility class for formatting messages requiring runtime parameters. Parameters substitution locations are indicated by the parameter name surrounded by braces. For example, a parameterized error message might be

Error {errorId}: The file {filename} could not be read.

When the error occurs, the message could be prepared for display with the following code:

     var template:String = "Error {errorId}:  The file {filename} could not be read.";
     var params:Object = new Object();
     params.errorId = 42;
     params.filename = "/Users/alice/vacation.jpg";
     var message:String = FormatMessage.formatString(template, params);
     // message="Error 42:  The file /Users/alice/vacation.jpg could not be read."
     

The ActionScript object literal syntax is a convenient way to construct the parameter object. The following is functionally equivalent to the code above:

     var template:String = "Error {errorId}:  The file {filename} could not be read.";
     var params:Object =
             {
                 errorId:  42,
                 filename: "/Users/alice/vacation.jpg"
             };
     var message:String = FormatMessage.formatString(template, params);
     // message="Error 42:  The file /Users/alice/vacation.jpg could not be read."
     

Note that traditional numeric parameters are supported by simply using an Array as the parameter object:

     var template:String = "Error {0}:  The file {1} could not be read.";
     var params:Array =
             [
                 42,
                 "/Users/alice/vacation.jpg"
             ];
     var message:String = FormatMessage.formatString(template, params);
     // message="Error 42:  The file /Users/alice/vacation.jpg could not be read."
     

Note that for missing parameters, the empty string will be used:

     var template:String = "Error {errorId}:  The file {filename} could not be read.";
     var params:Object =
             {
                 errorId:  42,
             };
     var message:String = FormatMessage.formatString(template, params);
     // message="Error 42:  The file  could not be read."
     

Note that parameters are substituted verbatim, no parameter replacement or brace processing is performed on the parameters themselves:

     var template:String = "{one}{two}{three}{four}{five}";
     var params:Object =
             {
                 one: "{five}",
                 two: "{four}",
                 three: "{three}",
                 four: "{two}",
                 five: "{one}"
             };
     var message:String = FormatMessage.formatString(template, params);
     // message="{five}{four}{three}{two}{one}"
     

To escape an opening brace, double the initial brace:

     var template:String = "The {{filename} parameter is {filename}.";
     var message:String = FormatMessage.formatString(template, {filename: "/Users/alice/vacation.jpg"});
     // message="The {filename} parameter is /Users/alice/vacation.jpg."
     

Best practice: It can be useful to use formatString on all strings, parameterized or not, to ensure that escaping rules are consistent between parameterized and non-parameterized strings (since strings that were unparameterized may become parameterized and vice-versa).



Общедоступные свойства
 СвойствоОпределено
 Inheritedconstructor : Object
Ссылка на объект класса или функцию конструктора для данного экземпляра объекта.
Object
Общедоступные методы
 МетодОпределено
  
formatString(message:String, parameters:Object):String
[статические] Given a message string, perform parameter substitution on it.
FormatMessage
 Inherited
Показывает, определено ли заданное свойство для объекта.
Object
 Inherited
Показывает, есть ли экземпляр класса Object в цепи прототипов объекта, заданного в качестве параметра.
Object
 Inherited
Показывает наличие заданного свойства и его перечисляемость.
Object
 Inherited
Задает доступность динамического свойства для операций цикла.
Object
 Inherited
Возвращает строковое представление этого объекта, отформатированного в соответствии со стандартами, принятыми для данной локали.
Object
 Inherited
Возвращает строковое представление заданного объекта.
Object
 Inherited
Возвращает элементарное значение заданного объекта.
Object
Сведения о методе

formatString

()метод
public static function formatString(message:String, parameters:Object):String

Язык версии: ActionScript 3.0
Версия продукта: Adobe Digital Enterprise Platform Experience Services - Client Component Framework 10
Версии среды выполнения: AIR 1.1, Flash Player 9

Given a message string, perform parameter substitution on it.

Параметры

message:String — The parameterized message string. Must not be null.
 
parameters:Object — An object with a property for each parameter that is to be substituted into the message. May be null (which means there are no parameters to be substituted).

Возвращает
String — The message string with any parameter substitution performed.




[ X ]Почему по-английски?
Содержимое Справочника ActionScript 3.0 отображается на английском языке

Не все части Справочника ActionScript 3.0 переводятся на все языки. Если какой-то текстовый элемент не переведен, он отображается на английском языке. Например, компонент ga.controls.HelpBox не переведен ни на один из языков. Это значит, что в русской версии справки компонент ga.controls.HelpBox будет отображаться на английском языке.