Length (String.length Property) - 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

length (String.length property)

public length :
Number
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
Availability: ActionScript 1.0; Flash Lite 2.0
Example
The following example creates a new String object and uses
number of characters:
var my_str:String = "Hello world!";
trace(my_str.length); // output: 12
The following example loops from 0 to
within a string, and if the string contains the
it does not contain the
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 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
my_str.length
character, then
@
false
String.length
. The code checks the characters
character,
displays in the Output panel. If
@
true
displays in the Output panel.
is
x
to count the
String
633

Advertisement

Table of Contents
loading

Table of Contents