Graphics Programs Reference
In-Depth Information
Figure 7.1 Sample screen shot from puppyCam.swf
Step 1: Initialize the incremental camera movement and speed
Let's begin by initializing two variables, camdz , which will control the movement of the
camera in and out, and camdx , which will control the movement of the camera left and
right. We will also define the variable camspeed , which will control how fast the camera
moves. Insert the lines below to initialize these variables.
// set the viewer/camera distance d from the screen
var d:Number = 100;
1
2
3
4
5
6
7
// initialize the incremental camera movement and speed
var camdz:Number = 0;
var camdx:Number = 0;
var camspeed:Number = 5;
Step 2: Add some camera movement
We are going to put the camera movement under user control. Let's use the arrow keys
to do that. The Up Arrow and Down Arrow keys will enable the camera to zoom in and
out, while the Left Arrow and Right Arrow keys will allow the camera to pan left and
right. We'll need to put this inside the onEnterFrame handler to see the movement.
 
Search WWH ::




Custom Search