Graphics Programs Reference
In-Depth Information
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// create the movement under mouse control
this.onEnterFrame = function()
{
// when the mouse is at some location on the Stage,
// we want to move to the corresponding point
// on the background -- the target
target = xo - scale * (_xmouse - xo);
// if the background location
// is less than the target location
if ( obj[0]._x < target - 2)
{ obj[0]._x += speed;
obj[1]._x += 2.14 * speed;
obj[2]._x += 2.14 * speed;
obj[3]._x += 2.00 * speed;
obj[4]._x += 1.85 * speed;
obj[5]._x += 1.71 * speed;
obj[6]._x += 1.55 * speed;
obj[7]._x += 1.43 * speed;
obj[8]._x += 1.29 * speed;
obj[9]._x += 1.14 * speed;
obj[10]._x += 1.14 * speed;
}
//else if the background location
// is greater than the target location
if ( obj[0]._x > target + 2)
{ obj[0]._x -= speed;
direction. If we stop the background movement, then we must stop the movement of
the rest of the objects. For each of them, they must stop at xmax plus one-half of the
difference between the object's width and the background's width. For example, for
a foreground object, its width was resized from the 1200 pixels of the background to
2000 pixels. The difference between the two widths is 800 pixels, so the foreground
must stop at xmax plus 400.
A similar test must be performed to keep the background from sliding off the Stage
in the other direction. The code is the same except for a minus sign.
Search WWH ::




Custom Search