String.substring() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

String.substring()

Availability
Flash Player 5.
Usage
my_str.substring(start:Number, [end:Number]) : String
Parameters
A number; an integer that indicates the position of the first character of
start
create the substring. Valid values for
negative value, 0 is used.
A number; an integer that is 1+ the index of the last character in
end
Valid values for
end
is not included in the extracted string. If this parameter is omitted,
parameter is a negative value, 0 is used.
Returns
String: a substring of the specified string.
Description
Method; returns a string comprising the characters between the points specified by the
parameters. If the
end
string. If the value of
value of
is greater than the value of
start
the function executes and the original value is unchanged.
Example
The following example shows how to use
var my_str:String = "Hello world";
var mySubstring:String = my_str.substring(6,11);
trace(mySubstring); // output: world
The following example shows what happens if a negative
var my_str:String = "Hello world";
var mySubstring:String = my_str.substring(-5,5);
trace(mySubstring); // output: Hello
An example is also in the Strings.fla file in the Examples folder. The following list gives typical
paths to this folder:
Windows: \Program Files\Macromedia\Flash MX 2004\Samples\HelpExamples\
Macintosh: HD/Applications/Macromedia Flash MX 2004/Samples/HelpExamples/
start
are 1 through
String.length
parameter is not specified, the end of the substring is the end of the
end
equals the value of
start
substring()
are 0 through
String.length
. The character indexed by the
, the method returns an empty string. If the
end
, the parameters are automatically swapped before
end
:
start
my_str
- 1. If
start
to be extracted.
my_str
end
is used. If this
String.length
parameter is used:
String.substring()
used to
is a
parameter
and
start
807

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents