Using ActionScript for Animation
7.Choose the Paint Bucket tool, change the selected color to white, and then click inside the bounds of the tail area.
8.Rename the layer to Helicopter. Create a new layer by clicking the new layer button below the layer. Rename the new layer to Rear Rotor.
9.Click the Oval tool in the Tools palette, select a dark grey from the line color chooser, select a medium grey from the background color chooser, and draw a circle roughly 11 pixels in diameter centered around the top of the tail.
10.Click the Scene 1 button on top of the timeline to return to the main timeline. Click the first frame in the timeline, open the Actions panel (Window Development Panels Actions), and type in the following ActionScript code:
#include “tryItOut_helicopterAnimation.as”
11.Select File Save As, name the file tryItOut_helicopterAnimation.fla, choose an appropriate directory, and save it.
12.Create a new script file by selecting File New and choosing ActionScript File from the New Document panel.
13.Select File Save As and ensure it is showing the same directory containing the Flash project file. Give the file the name tryItOut_helicopterAnimation.as and save it.
14.Enter the following code into the new ActionScript file:
var ACCELERATION_RATE:Number = 0.4; var EASING_FACTOR:Number = 10;
var MOVEMENT_AMOUNT:Number = 7;
this.createEmptyMovieClip(“holderClip”, this.getNextHighestDepth()); holderClip.attachMovie(“helicopter”, “helicopter”, holderClip.getNextHighestDepth());
holderClip.helicopter.targetX = 275; holderClip.helicopter.verticalSpeed = 0; holderClip.helicopter._x = holderClip.helicopter.targetX; holderClip.helicopter._y = Stage.height - 14;
var intervalID:Number = setInterval(updateAnimation, 20); function updateAnimation()
{
checkKeys();
holderClip.helicopter._x += (holderClip.helicopter.targetX - ; holderClip.helicopter._x) / EASING_FACTOR;
holderClip.helicopter._rotation = ; Math.min((holderClip.helicopter.targetX - ; holderClip.helicopter._x) / 5, 20);
holderClip.helicopter.verticalSpeed += ACCELERATION_RATE;
holderClip.helicopter._y += holderClip.helicopter.verticalSpeed; if (holderClip.helicopter._y >= Stage.height - 14)
{
holderClip.helicopter._y = Stage.height - 14;