Graphics Programs Reference
In-Depth Information
The next set of code happens with the onEnterFrame of the main Timeline ( _root ).
It checks to see whether the Up Arrow or Down Arrow key is pressed on the keyboard.
Depending on which one is pressed, each of the five doorways is scaled differently. The
difference in scaling will create the illusion of depth.
There are two more conditions that Flash checks before it scales the doorways. When
the user presses the Up Arrow key, Flash calculates whether or not the smallest door's
horizontal dimension ( door1_mc ) is smaller than the original horizontal dimension of
door5_mc . The original dimension was stored in the variable stopZoomIn . If the dimen-
sion is smaller, the doors will scale. Once the horizontal dimension of door1_mc equals
the original dimension of door5_mc , the doorways stop scaling.
The other condition occurs when the user presses the Down Arrow key. Flash checks to
see whether the horizontal dimension of door1_mc is not smaller than its original hori-
zontal dimension. The original dimension was stored in the variable stopZoomOut .
Step 5: Save and test movie
Save and test your movie. Choose Control > Test Movie to see the results. Press the Up
Arrow and Down Arrow keys to scale the doorways. The next step is to make the char-
acter react to the movement.
Step 6: Enter the ActionScript
Add to the bottom of the ActionScript as shown.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
man_mc.onEnterFrame = function()
{
if (animate=="backward"){
this.gotoAndStop("backward");
}
if (animate=="forward"){
this.gotoAndStop("forward");
}
if (animate=="stop"){
this.gotoAndStop("stop");
}
}
Key.addListener(man_mc);
man_mc.onKeyUp = function(){
animate = "stop";
}
Search WWH ::




Custom Search