Detailed instructions for use are in the User's Guide.
[. . . ] Flash Lite 1. x ActionScript Language Reference
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Endocer, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] Some properties cannot be enumerated by the for or for. . in statements. For example, movie clip properties, such as _x and _y, are not enumerated.
Example
The following example uses the for loop to sum the numbers from 1 to 100:
sum = 0; for (i = 1; i <= 100; i++) { sum = sum + i; }
See also
++ (increment), (decrement), do. . while, while
for
71
if
Availability
Flash Lite 1. 0.
Usage
if (condition) { statement(s); }
Parameters
condition
An expression that evaluates to true or false. The instructions to execute if the condition evaluates to true.
statement(s)
Description
Statement; evaluates a condition to determine the next action in a SWF file. If the condition is true, Flash Lite runs the statements that follow the condition inside curly braces ({}). If the condition is false, Flash Lite skips the statements inside the curly braces and runs the statements following the braces. Use the if statement to create branching logic in your scripts.
Example
In the following example, the condition inside the parentheses evaluates the variable name to see if it has the literal value "Erica". If it does, the play() function runs.
if(name eq "Erica"){ play(); }
72
Flash Lite Statements
switch
Availability
Flash Lite 1. 0.
Usage
switch (expression){ caseClause: [defaultClause:] }
Parameters
expression caseClause
Any numeric expression.
A case keyword followed by an expression, a colon, and a group of statements to execute if the expression matches the switch expression parameter.
defaultClause
An optional default keyword followed by statements to execute if none of the case expressions match the switch expression parameter.
Description
Statement; creates a branching structure for ActionScript statements. Similar to the if statement, the switch statement tests a condition and executes statements if the condition evaluates to true. Switch statements contain a fallback option called default. If no other statements are true, the default statement is executed.
switch
73
Example
In the following example, if the myNum parameter evaluates to 1, the trace() statement that follows case 1 executes; if the myNum parameter evaluates to 2, the trace() statement that follows case 2 executes; and so on. If no case expression matches the number parameter, the trace() statement that follows the default keyword executes.
switch (myNum) { case 1: trace ("case 1 tested true"); break; case 2: trace ("case 2 tested true"); break; case 3: trace ("case 3 tested true"); break; default: trace ("no case tested true") }
In the following example, the first case group doesn't contain a break, so if the number is 1, both A and B appear in the Output panel:
switch (myNum) { case 1: trace ("A"); case 2: trace ("B"); break; default: trace ("D") }
See also
case
while
Availability
Flash Lite 1. 0.
Usage
while(condition) { statement(s); }
74
Flash Lite Statements
Parameters
condition
The expression that is evaluated each time the while statement executes. The instructions to execute when the condition evaluates to true.
statement(s)
Description
Statement; tests an expression and runs a statement or series of statements repeatedly in a loop as long as the expression is true. Before the statement block is run, the condition is tested; if the test returns true, the statement block is run. If the condition is false, the statement block is skipped and the first statement after the while statement's statement block is executed. Looping is commonly used to perform an action when a counter variable is less than a specified value. At the end of each loop, the counter is incremented until the specified value is reached. At that point, the condition is no longer true, and the loop ends. The while statement performs the following series of steps. Each repetition of steps 1 through 4 is called an iteration of the loop. The condition is tested at the beginning of each iteration:
1. 2.
The expression condition is evaluated. If condition evaluates to true or a value that converts to the Boolean value true, such as a nonzero number, go to step 3. [. . . ] type One of the values Numeric, Alpha, Alphanumeric, Latin, NonLatin, or NoRestriction.
Flash Lite supports input text functionality by asking the host application to start the generic device-specific text input interface, often referred to as the front-end processor (FEP). When the SetInputTextType command is not used, the FEP is opened in default mode.
152
Flash Lite Specific Language Elements
The following table shows what effect each mode has, and what modes are substituted:
Mode specified
Numeric Alpha Alphanumeric Latin NonLatin NoRestriction
N OT E
Sets the FEP to one of these mutually exclusive modes
Numbers only (0 to 9) Alphabetic characters only (A to Z, a to z) Alphanumeric characters only (0 to 9, A to Z, a to z) Latin characters only (alphanumeric and punctuation) Non-Latin characters only (for example, Kanji and Kana) Default mode (sets no restriction on the FEP)
If not supported on current device, opens the FEP in this mode
Alphanumeric Alphanumeric Latin NoRestriction NoRestriction
Not all mobile phones support these input text field types. For this reason, you must validate the input text data.
Example
The following line of code sets the input text type of the field associated with the input1 variable to receive numeric data:
status = fscommand2("SetInputTextType", "input1", "Numeric");
SetQuality
Availability
Flash Lite 1. 1.
Description
Sets the quality of the rendering of the animation.
Command
"SetQuality"
Parameters
quality "high", "medium", or "low".
Value returned
The rendering quality; must be -1: Not supported. 0: Supported.
Example
The following example sets the rendering quality to low:
status = fscommand2("SetQuality", "low");
fscommand2()
153
SetSoftKeys
Availability
Flash Lite 1. 1.
Description
Remaps the Left and Right soft keys of the device, provided that they can be accessed and remapped. [. . . ]