MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 466

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

To create an array of substrings segmented by delimiter:
1.
Create a new Flash document and save it as strsplit.fla.
2.
Add the following ActionScript to Frame 1 of the main Timeline:
var queryStr:String = "first=joe&last=cheng&title=manager&startDate=3/6/
65";
var params:Array = queryStr.split("&", 2);
trace(params); // first=joe,last=cheng
/* params is set to an array with two elements:
params[0] == "first=joe"
params[1] == "last=cheng"
*/
3.
Select Control > Test Movie to test the Flash document.
The second parameter of the
If you don't want to limit the size of the array created by the
omit the second parameter.
The easiest way to parse a query string (a string delimited with & and = characters) is
to use the
LoadVars.decode()
var queryStr:String = "first=joe&last=cheng&title=manager&startDate=3/6/
65";
var my_lv:LoadVars = new LoadVars();
my_lv.decode(queryStr);
trace(my_lv.first); // joe
For more information on using operators with strings, see
strings" on page
182.
You can find a sample source file, strings.fla, in the Samples folder on your hard disk. This file
shows you how to build a simple word processor that compares and retrieves string and
substring selections.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Strings.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Strings.
466
Working with Text and Strings
method defines the maximum size of the array.
split()
method, as shown in the following ActionScript:
"About using operators with
method, you can
split()

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents