1. Home
  2. Computing & Technology
  3. Animation

ActionScripting Basics: Collision Test Using hitTest

By Adrien-Luc Sanders, About.com

10 of 10

After the stop, insert a gotoAndStop command, with the following modifications:

_root.target.gotoAndStop(2) ;

To Flash, that translates to: ”Get out of this movie clip’s timeline; go back up to the root level of the movie and the maintime line, and find the movie clip instance that we’ve named target. Go to frame 2 of that movie clip, and when you get there, stop.”

And really, that’s it. Until you get used to nesting conditions and functions like this, it can be a bit of a headache; a new syntax is always hard to learn, but once you’ve practiced a few times you develop a higher level of comfort—and the hitTest function is a good one to learn on. Basically all that you need to remember is that a function performs an assigned task upon whatever parameter or name is inside of its ( ) parentheses; a condition will perform whatever functions are inside of its { } brackets, once its requirements are met—whether those requirements are a release of a mouse click in an on (release) command or a specific function contained as part of an if/else statement.

And with that overwith, take a look at the scripts in action.

Explore Animation
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Animation
  4. Flash Animation Tutorials
  5. ActionScripting Basics: Collision Test Using hitTest

©2009 About.com, a part of The New York Times Company.

All rights reserved.