![MACROMEDIA Flash Lite 2 Скачать руководство пользователя страница 638](http://html1.mh-extra.com/html/macromedia/flash-lite-2/flash-lite-2_reference_687553638.webp)
638
ActionScript classes
Example
The following example creates a new string,
my_str
and uses
substr()
to return the second
word in the string; first, using a positive
start
parameter, and then using a negative
start
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
start
and
end
parameters. If the
end
parameter is not specified, the end of the substring is the end of the
string. If the value of
start
equals the value of
end
, the method returns an empty string. If
the value of
start
is greater than the value of
end
, the parameters are automatically swapped
before the function executes and the original value is unchanged.
Availability:
ActionScript 1.0; Flash Lite 2.0
Parameters
start
:
Number
- An integer that indicates the position of the first character of
my_str
used to
create the substring. Valid values for
start
are 0 through
String.length
- 1. If
start
is a
negative value, 0 is used.
end
:
Number
- An integer that is 1+ the index of the last character in
my_str
to be extracted.
Valid values for
end
are 1 through
String.length
. The character indexed by the
end
parameter is not included in the extracted string. If this parameter is omitted,
String.length
is used. If this parameter is a negative value, 0 is used.
Returns
String
- A substring of the specified string.
Содержание Flash Lite 2
Страница 1: ...Flash Lite 2 x ActionScript Language Reference...
Страница 22: ...22 Contents...
Страница 244: ...244 ActionScript language elements...
Страница 760: ...760 ActionScript classes...