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

Home > Articles > Design > Adobe Creative Suite

📄 Contents

  1. Changing a Property Value
  2. Changing Position
  3. Increasing or Decreasing a Property's Value
  • Print
  • + Share This
Like this article? We recommend

Increasing or Decreasing a Property's Value

Rather than setting a property to a specific value, you can add to or subtract from its current value. For example, rather than rotating the star in the previous example by 90 degrees, you could write code that would take the current amount of rotation and add to or subtract from it.

The following steps create some code that adds five degrees to the star's rotation every time it's clicked:

  1. Select and delete all the code that was typed in the Actions panel in the previous procedure, replacing it with the following code:
    star_mc.addEventListener(MouseEvent.CLICK, rotateStar);
    function rotateStar(e:MouseEvent):void{
     star_mc.rotation+=5;
    }
  2. Now test the movie. Each time the star is clicked, it should rotate an additional five degrees.

    Using += in the code is a shorthand way of saying "Take the current value of the object on the left and add the value on the right to it." Here's the longhand way to do the same thing:

    star_mc.rotation = star_mc.rotation + 5;
  • + Share This
  • 🔖 Save To Your Account