tailieunhanh - Học Actionscript 3.0 - p 6

Conditionals 3. Compound assignment operators work a bit like increment and decrement operators, but they are not restricted to altering an expression by a value of 1. Instead, they alter the original based on whatever is to the right of the equal sign. For example, 10 += 5 is 15 and is equivalent to saying 10 = 10 + 5. 4. Note the difference between the assignment operator (=, a single equal sign) and the comparison equality operator (==, a double equal sign). The first assigns a value to an expression; the second tests whether two values are equal. Both comparison. | Conditionals 3. Compound assignment operators work a bit like increment and decrement operators but they are not restricted to altering an expression by a value of 1. Instead they alter the original based on whatever is to the right of the equal sign. For example 10 5 is 15 and is equivalent to saying 10 10 5. 4. Note the difference between the assignment operator a single equal sign and the comparison equality operator a double equal sign . The first assigns a value to an expression the second tests whether two values are equal. Both comparison and logical operators are discussed later in the Conditionals section of this chapter. 5. The as and is operators are discussed earlier in the Casting section of this chapter. 6. When used in the context of strings the plus symbol is a concatenation operator which joins two strings together. The expression Sally Claire evaluates to SallyClaire . NOTE Additional ActionScript operators can be found at http www. livedocs flash 90 ActionScriptLangRefV3 . Arithmetic Operator Precedence Arithmetic and arithmetic compound assignments are evaluated in order of precedence. Multiplication division and modulo are executed first and addition and subtraction are executed second. For example 1 2 3 4 is equivalent to five and two-thirds because the division is evaluated before the addition. Parentheses can alter the order of precedence by evaluating their contents first. Changing the previous expression to 1 2 3 4 is equivalent to three-sevenths because the addition is evaluated before the division. Conditionals You will often need to make a decision in your script choosing to do one thing under one circumstance and another thing under a different circumstance. These situations are usually handled by conditionals. Put simply a test asks whether a condition is met. If the condition is met the test evaluates to true and specific code is executed accordingly. If the condition is not met either no further action is