Graphics Programs Reference
In-Depth Information
Since all of the flags are contained in movie clips that have been created inside the
scene3D movie clip, we can write a function for the user clicking on the scene (line
89). There is nothing else in the scene but the flags, so we can set up a for loop to
loop over them (line 92). We can tell which flag has been selected in line 96 by using a
movie clip hitTest() method to check whether the cursor ( _xmouse,_ymouse ) has hit
a flag.
Once the flag has been determined, the visibility of flag_txt is turned on (line 99).
After grabbing the name of the country from flagArray , it is put into the text of
flag_txt (line 100) and displayed on the screen.
// ----------------------------------------------------------
// define the background and scene actions
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// click on a flag to move the viewer towards it
scene3D.onRelease = function()
{
// loop over the objects in the scene
for (k=1; k<=numberOfObjects; k++)
{
thisObj = scene3D["object"+k];
// find the selected flag
if ( thisObj.hitTest(_xmouse,_ymouse) )
{
// turn on the selected flag message
title_mc.flag_txt._visible = true;
title_mc.flag_txt.text =
"You clicked on the flag of " + flagArray[k];
// set the viewer destination coordinates
viewer.dx = thisObj.x;
viewer.dy = thisObj.y;
viewer.dz = thisObj.z/2;
break; // break out of the loop
}
}
}
// click on background to zoom out
var back:Boolean = false;
bg_mc.onRelease = function() {back = true; }
 
Search WWH ::




Custom Search