Graphics Programs Reference
In-Depth Information
When you zoom in sufficiently toward the knight guarding the queen, the knight will
swing his axe at you as shown in Figure 7.36. The test to activate this animation is
carried out in the onEnterFrame handler.
Figure 7.36 Screen shot of the guard animation
There are several ways in which a test may be set up. The way in which it was done
here was to observe that as you zoom in on the guard, his size changes because the
viewer is closer. The displayObj() function performs this by applying the perspective
ratio to the _xscale and _yscale of each object. Using a trace(scene3D.Guard.
_xscale) command while zooming in provided the desired scale factor.
The Guard movie clip contains the animation sequence. Once the scale factor has been
reached, the script below activates that sequence. A gotoAndPlay(scene3D.Guard.
_currentframe + 1) statement is issued that tells Flash to play the next frame of the
animation. At the end of the sequence, the playback head returns to the first frame and
keeps looping. If the scale is less than 100, the sequence stops at the first frame.
102
103
104
105
106
// test to activate the guard animation
if (scene3D.Guard._xscale > 100)
{scene3D.Guard.gotoAndPlay(scene3D.Guard._currentframe + 1);}
else { scene3D.Guard.gotoAndStop(1); }
Search WWH ::




Custom Search