type = 'application/x-shockwave-flash'
data = 'http://sitepointstatic.com/flash/hittest.swf'
width = '400'
height = '400'
bgcolor = 'black'

Download the sample files here.

1. Create a new movie with width=400 and height=300.

2. Create two rectangles, one that’s red and one that’s blue.

3. Convert the first red rectangle into a movieclip, and name it "red" in the instance box.

4. Convert the second blue rectangle into a movieclip and name it "blue" in the instance box.

5. Create a text field, and name it "information".

6. Create a new layer above the current layer, and name it "actions".

7. Insert the following action into the first key frame:

if (circle.hittest(red))  
information = "The Circle Hit Red";  
if (circle.hittest(blue))  
information = "The Circle Hit Blue";  

8. In the second frame, enter this action:

gotoAndPlay (1); 

9. Now, simply press ctrl+enter to test the movie.

Georgina has more than fifteen years' experience writing and editing for web, print and voice. With a background in marketing and a passion for words, the time Georgina spent with companies like Sausage Software and sitepoint.com cemented her lasting interest in the media, persuasion, and communications culture.

No Reader comments

Special Offer
Free course!

Git into it! Bonus course Introduction to Git is yours when you take up a free 14 day SitePoint Premium trial.