適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: 從伺服器擷取資料...
從伺服器擷取資料...
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 類別就會以英文顯示。