Basics of strings

Introduction to working with strings

In programming parlance, a string is a text value--a sequence of letters, numbers, or other characters strung together into a single value. For instance, this line of code creates a variable with the data type String and assigns a literal string value to that variable:

var albumName:String = "Three for the money";

As this example shows, in ActionScript you can denote a string value by surrounding text with double or single quotation marks. Here are several more examples of strings:

"Hello"
"555-7649"
"http://www.adobe.com/"

Any time you manipulate a piece of text in ActionScript, you are working with a string value. The ActionScript String class is the data type you can use to work with text values. String instances are frequently used for properties, method parameters, and so forth in many other ActionScript classes.

Common tasks for working with strings

The following are common string-related tasks that are explored in this chapter:

Important concepts and terms

The following reference list contains important terms that you will encounter in this chapter:

Working through in-chapter examples

As you're working through the chapter, you may want to test some of the example code listings for yourself. Because the code listings in this chapter deal primarily with manipulating text, testing the examples will involve viewing the values of the variables used in the examples, either by writing values into a text field instance on the Stage or by using the trace() function to print values to the Output panel. These techniques are described in detail in Testing in-chapter example code listings.


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000077.html