Testing for a hit

 
     
 

Back

Next

 
     
 

To check if a word has been dropped in the right place, alter the code already attached to the word1 symbol. The new code is in blue.

on (press) {
startDrag (this,false);
}

on (release) {
stopDrag();
if (this.hitTest(_root.box1) == true){
trace("you got it right");

}
}

When the word is dropped, the function checks if it is over box1. If it is a window will open giving the message. You will improve on this later but for now, test the movie to check the code.

The logical next step is to get the function to give an alternative message if the word is dropped in a different place. Edit the code again by adding the instruction in blue.

on (press) {
startDrag (this,false);
}

on (release){
stopDrag();
if (this.hitTest(_root.box1) == true){
trace("you got it right");
}
else trace("oops, try again");
}

If you test the movie, you will find that this solution has the problem that the output window that contains the message hides a lot of the screen and has to be closed if the user is to carry on. The next section will give feedback in a different way.

 
   
 
     
 

Back

Next