Substring (String.substring Method) - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

Example
The following example creates a new string,
word in the string; first, using a positive
parameter:
var my_str:String = new String("Hello world");
var mySubstring:String = new String();
mySubstring = my_str.substr(6,5);
trace(mySubstring); // output: world
mySubstring = my_str.substr(-5,5);
trace(mySubstring); // output: world
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 Lite 2.0
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
638
ActionScript classes
start
parameter is not specified, the end of the substring is the end of the
equals the value of
start
start
String.length
and uses
my_str
substr()
parameter, and then using a negative
, the method returns an empty string. If
end
, the parameters are automatically swapped
end
are 0 through
String.length
. The character indexed by the
to return the second
start
and
start
end
used to
my_str
- 1. If
is a
start
to be extracted.
my_str
end
String.length

Advertisement

Table of Contents
loading

Table of Contents