Graphics Programs Reference
In-Depth Information
Step 4: Enter the ActionScript
Enter the ActionScript as shown.
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
28
29
30
//stop the main timeline
stop();
//record a stopping point for the zooming
stopZoomIn = door5_mc._xscale;
stopZoomOut = door1_mc._xscale;
//zoom on keyPress
_root.onEnterFrame = function()
{
if (Key.isDown(Key.UP)) {
if (door1_mc._xscale < stopZoomIn){
door1_mc._xscale = door1_mc._yscale += .5;
door2_mc._xscale = door2_mc._yscale += 1;
door3_mc._xscale = door3_mc._yscale += 2;
door4_mc._xscale = door4_mc._yscale += 4;
door5_mc._xscale = door5_mc._yscale += 8;
}
}
if (Key.isDown(Key.DOWN)) {
if (door1_mc._xscale <> stopZoomOut){
door1_mc._xscale = door1_mc._yscale -= .5;
door2_mc._xscale = door2_mc._yscale -= 1;
door3_mc._xscale = door3_mc._yscale -= 2;
door4_mc._xscale = door4_mc._yscale -= 4;
door5_mc._xscale = door5_mc._yscale -= 8;
}
}
}
Let's deconstruct the script. You are recording the horizontal dimensions ( _xscale )
of the largest door ( door5_mc ) and the smallest door ( door1_mc ) in two variables.
Variables act as storage containers for data. These variables can be called later in the
script to retrieve the stored information. Why store this information? These variables
will prevent the doorways from scaling too big or too small.
stopZoomIn = door5_mc._xscale;
stopZoomOut = door1_mc._xscale;
Search WWH ::




Custom Search