Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
This chapter is from the book

Wrapping Up

In this chapter, you learned the basics of working with variables and how to change numeric values using arithmetic operators in ActionScript. You also learned some of the common shortcuts advanced programmers use to save time when working with math operators, including working with combined assignment operators and the increment and decrement operators.

When working with operators in ActionScript, keep the following in mind to avoid common pitfalls and errors:

  • When creating a variable and referring to it the first time, you need to use the var statement to create it. You can then refer to it without the var statement afterwards.
  • When using the + operator, be sure to not inadvertently mix up strings and numbers, as strings will concatenate and ignore the numeric values.
  • The modulo operator calculates the remainder after attempting to complete an even division.
  • If you are working with a combination of multiplicative (multiplication, division, or modulo) functions and summation (addition or subtraction) functions, remember that ActionScript will evaluate your equation using mathematical order of operations.
  • To quickly modify an existing value based on a function, you can use combined assignment operators to save time.
  • If you are adding or subtracting 1 to or from a value, you can use increment or decrement operators, using ++ or -- as a quick shortcut.
  • To force the order of operations to do something specific, you can use parentheses to group evaluations you want to process first.
  • + Share This
  • 🔖 Save To Your Account