String.concat( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
String.concat( ) Method Flash 5

combine one or more values into a single string
string.concat(value1, value2,...valuen)

Arguments

value1,...valuen

Values to be converted to strings (if necessary) and concatenated with string.

Returns

The result of concatenating string with value1, value2, ...valuen.

Description

The concat( ) method creates a string from a series of values. It is equivalent to using the concatenation operator (+) with strings but is sometimes preferred for clarity, as the + operator can also be used to add numbers. For details on concat( ), see Chapter 4.

Usage

Note that concat( ) does not modify string; it returns a completely new string.

Example

var greeting = "Hello"; excitedGreeting = greeting.concat("!"); trace(greeting);                         // Displays: "Hello" trace(excitedGreeting);                  // Displays: "Hello!"     var x = 4;                               // Initialize x as an integer trace(x + 5);                            // Displays: 9 trace(x.concat(5));                      // Fails because x is not a string trace(String(x).concat(5));              // Displays: "45"     var x = "4";                             // Initialize x as a string trace(x.concat(5));                      // Displays: "45" trace(concat("foo", "fee"));             // Fails because concat( ) must be                                          // invoked as a method of a string

See Also

Section 4.6.1 and Section 4.6.1.1; Section 5.3.1



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net