• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

ActionScript Reference

ActionScript Reference

You might notice that I've added something here that's not in most reference sections: Uses. I've included some information about why you might use a certain method or property. Hope fully, this will make this reference a little more useful and educational than simply a dry listing of syntax conventions and simple examples.

-- (decrement)
Syntax
-- expression
expression -

Arguments The expression can be a variable, number, element in an array, or the property of an object.
Description This operator subtracts 1 from the expression. Depending on the syntax used, it's either a pre-decrement or a post-decrement. A pre-decrement (--expression) subtracts 1 from the expression and returns the result. A post-decrement (expression--) subtracts 1 from the expression and returns the initial value of the expression.
Player Flash 4 or later
Examples Pre-decrement
x = 3;
y = --x;

Both x and y now have value of 2.

Post-decrement

x = 3;
y = x--;

x has a value of 2, but y has a value of 3.

for (i=10; i>0, i--)
{
statements
}

The variable i decrements from 10 down to 1.
Uses Use decrementing to subtract 1 from any variable. You'll find decrementing used most often in loops, as in the example. They're good for updating counters or indices.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint