## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Applying Animation Techniques to Other Properties

## Problem

You want to apply the techniques in this chapter’s recipes to something other than an object’s motion.

## Solution

Apply the techniques as given, but assign the results to a property other than the object’s x and y position.

## Discussion

Although changing an object’s position is the most obvious method of animation, all of the techniques in this chapter can be applied to almost any property of a movie clip or sprite. This recipe provides several examples to get you started, but the possibilities are so numerous that it would be impossible to list them all.

First, try applying some velocity to the rotation property; this variable is called `_vr` for rotational velocity:

```package {
import flash.display.Sprite;
import flash.events.Event;

public class AnimatingRotation extends Sprite {
private var _sprite:Sprite;
private var _vr:Number = 4;

public function AS3CB() {
_sprite = new Sprite();
_sprite.graphics.beginFill(0xffffff, 100);
_sprite.graphics.drawRect(-50, -20, 100, 40);
_sprite.graphics.endFill();
_sprite.x = 100;
_sprite.y = 100;
}

public function onEnterFrame(event:Event):void {
_sprite.rotation += _vr;
}
}
}```

This example uses a rectangle instead of a circle, so you can see the rotation in action. It sets _`vr` to 4, and then adds that to the sprite’s rotation on each frame.

The next example applies a spring formula to the scale of the sprite. A click handler sets a ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required