03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

You can declare multiple variables in one statement, separating the declarations with commas<br />

(although this syntax may reduce clarity in your code):<br />

var first:String = "Bart", middle:String = "J.", last:String = "Bartleby";<br />

Note: You must also use var when declaring properties inside class definitions in external<br />

scripts. Class files also support public, private, <strong>and</strong> static variable scopes.<br />

Parameters<br />

variableName:String - An identifier.<br />

Example<br />

The following ActionScript creates a new array of product names. Array.push adds an<br />

element onto the end of the array. If you want to use strict typing, it is essential that you use<br />

the var keyword. Without var before product_array, you get errors when you try to use<br />

strict typing.<br />

var product_array:Array = new Array("MX 2004", "Studio", "Dreamweaver",<br />

"Flash", "ColdFusion", "Contribute", "Breeze");<br />

product_array.push("Flex");<br />

trace(product_array);<br />

// output: MX<br />

2004,Studio,Dreamweaver,Flash,ColdFusion,Contribute,Breeze,Flex<br />

while statement<br />

while(condition) { statement(s); }<br />

Evaluates a condition <strong>and</strong> if the condition evaluates to true, runs a statement or series of<br />

statements before looping back to evaluate the condition again. After the condition evaluates<br />

to false, the statement or series of statements is skipped <strong>and</strong> the loop ends.<br />

The while statement performs the following series of steps. Each repetition of steps 1 through<br />

4 is called an iteration of the loop. The condition is retested at the beginning of each<br />

iteration, as shown in the following steps:<br />

■ The expression condition is evaluated.<br />

■ If condition evaluates to true or a value that converts to the Boolean value true, such as<br />

a nonzero number, go to step 3. Otherwise, the while statement is completed <strong>and</strong><br />

execution resumes at the next statement after the while loop.<br />

■ Run the statement block statement(s).<br />

■ Go to step 1.<br />

206 ActionScript language elements

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!