Substring (String.substring Method) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

An example is also in the Strings.fla file in the ActionScript samples folder. The following list
gives typical paths to this folder:
Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript
Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/
Samples/ActionScript

substring (String.substring method)

public substring(start:Number, end:Number) : String
Returns a string comprising the characters between the points specified by the
parameters. If the
end
string. If the value of
the value of
is greater than the value of
start
before the function executes and the original value is unchanged.
Availability: ActionScript 1.0; Flash Player 5
Parameters
- An integer that indicates the position of the first character of
start:Number
create the substring. Valid values for
negative value, 0 is used.
- An integer that is 1+ the index of the last character in
end:Number
Valid values for
are 1 through
end
parameter is not included in the extracted string. If this parameter is omitted,
is used. If this parameter is a negative value, 0 is used.
Returns
- A substring of the specified string.
String
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
1138
ActionScript classes
parameter is not specified, the end of the substring is the end of the
equals the value of
start
start
String.length
substring()
, the method returns an empty string. If
end
, the parameters are automatically swapped
end
are 0 through
String.length
. The character indexed by the
:
and
start
end
used to
my_str
- 1. If
is a
start
to be extracted.
my_str
end
String.length

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

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

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF