String.length - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

String.length

Availability
Flash Player 5.
Usage
my_str.length:Number
Description
Property; an integer specifying the number of characters in the specified String object.
Because all string indexes are zero-based, the index of the last character for any string
.
x.length - 1
Example
The following example creates a new String object and uses
of characters:
var my_str:String = "Hello world!";
trace(my_str.length); // output: 12
The following example loops from 0 to
string, and if the string contains the
contain the
character, then
@
function checkAtSymbol(my_str:String):Boolean {
for (var i = 0; i<my_str.length; i++) {
if (my_str.charAt(i) == "@") {
return true;
}
}
return false;
}
trace(checkAtSymbol("dog@house.net")); // output: true
trace(checkAtSymbol("Chris")); // output: false
An example is also in the Strings.fla file in the HelpExamples 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/
my_str.length
character,
@
true
displays in the Output panel.
false
String.length
. The code checks the characters within a
displays in the Output panel. If it does not
is
x
to count the number
String.length
801

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?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents