Lab 4: Hit Test and Collision Detection (October 8th, 2007)
SIn this lab, you will be using and adding to the code we've gone over in class.
See the code page for the FLA. You may not complete the entire lab by the end of class. Please
attempt to complete the lab by following the steps described below. Post whatever you've finished by the end of class, whatever
step you get to. There are three parts.
PART 1
Start with the Hit Test code discussed today in class. Using a for loop, dynamically create at least 8
MovieClips (obstacles), instead of the one shown in class.
Make it so that the guy you can move around utilizes the Hit Test discussed in class. That is,
make it so that the guy will run into, but not overlap each obstacle.
PART 2
Create a MovieClip of a simple box with two frames. Make the box a different color on each frame.
Make it so that if you click the box, it changes color.
Now, using a for loop, dynamically create at least 8 of these MovieClips on the stage. Position them
randomly. You should be able to change the color of each MovieClip by clicking on each one.
Now make it so there is always one, and only one, MovieClip selected at one time. When
you click on a MovieClip, the previous selected should turn back to unselected, and the new MovieClip should turn
selected.
Now, using the keyboard event code discussed last class, make it so that the current MovieClip selected can be
moved around up, down, left and right, using the keyboard.
Finally, using the Hit Test code we went over today in class, make it so that when moving the selected block around
on the stage, it will run into all the other MovieClips on the screen and not overlap them (treat them as boundaries).
PART 3
Combine PART 1 and PART 2 into the following:
When you are done, post both FLAs and SWFs to your website.