Graphics Programs Reference
In-Depth Information
By moving the cursor on the screen, we change the target point of the image, and we
will be able to move the image around on the Stage. The same idea can be used to
have the panning and scrolling of a rectangle in a small map control the movement
and display of a larger map in a window.
With this as a foundation, let's start to look at some code. It was convenient, although
not necessary, to define an object array that consists of all of the layer movie clips. The
background served as the initial element and as a reminder that everything will move
relative to it. Generally, the rest of the array was built from the foreground images to
those closest to the background.
The horizontal center of the Stage is defined as xo . We are also defining a speed factor
that will control how fast the background pans left and right. The scale variable is set
to the background width divided by the Stage width as discussed.
The next task is a little trickier, and that is how to move the separate layers or planes
in such a way as to create the effect of moving in a 3D space. The separate layers that
comprise the total image can be thought of as separate planes along the z-axis in 3D
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// define the array of object movie clips
// that are in the scene
obj = [];
obj[0] = this["background_mc"];
obj[1] = this["man_mc"];
obj[2] = this["twowomen_mc"];
obj[3] = this["jealouswoman_mc"];
obj[4] = this["bush_mc"];
obj[5] = this["mantophat_mc"];
obj[6] = this["tree1_mc"];
obj[7] = this["womanbluedress_mc"];
obj[8] = this["tree2_mc"];
obj[9] = this["middleground_mc"];
obj[10]= this["couple_mc"];
// define the center point and background speed
var xo:Number = Stage.width/2;
var speed:Number = 8;
// set scale to be the background width/Stage width
scale = obj[0]._width/Stage.width;
Search WWH ::




Custom Search