• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part I: Foundation > Manipulating Strings

Chapter 9. Manipulating Strings

Whereas storing the string data type in a variable is straightforward enough, manipulating a string can be much more difficult. After you have a string, you’ll often want to change it, extract just a portion, or analyze the characters contained within it. Perhaps you want to automatically capitalize the first letter in each word of a string. Or maybe you want to compare the user’s input text to a list of correct answers. Using the features of Flash’s String object, you can manipulate strings the way a word processor can “find and replace”—and much more.

Often the values for your string variables will come from the user; that is, a user will type text into an input text field. Gathering such string data is explained in detail in Chapter 10, “Keyboard Access and Modifying Onscreen Text,” when the Key, TextField, TextFormat, and Selection objects are covered. (The order I chose might seem backwards; you can’t manipulate a string before you acquire it.) In any event, just realize that you need to populate your variables with strings first. In fact, it’s realistic that your string variables can be populated without the user. For example, you may have a list of cities that populates an array. You could hard-wire this at the beginning of your movie. The point is that there’s a lot you can do with strings—with or without the user’s input.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint