Got a request?
Email us...

ActionScript Reference crumb.gif Operators crumb.gif - (minus)

- (minus)

The minus operator is used for negating and subracting. The same laws of math apply to the minus sign in ActionScript.

Example 1: Subracting
s = 10-8;
trace(s);

In the example above, 8 is subracted from 10. The code then returns a result of 2.

If the absolute value of the number being subracted is greater than the number it is being subracted from, the result will be a negative number.

s = 10-12;
trace(s);

In the example above, the code returns a value of -2.

Example 2: Negating
The minus operator can be used to make a number negative.

s = - (10 + 5);
trace(s);

The above code take the sum of 10 and 5, and gives it a negative value. The result of the above code is -15.

Example 3: Expressions
The minus operator is not limited to numbers only. It can be used on expressions with numeric values as well.

s = 20;
t = 15;
r = (s-t);
trace(r);

The code above assigns a value of 20 to s and a value of 15 to t. It then subracts t from s and assigns the resulting value to r. The result is 5.

REFERENCE SEARCH


RELATED ENTRIES

...action assignment)
= (assignment)

LINK TO US