Detecting hitTest
This used to detect whether the movie clip(mc1) overlaps or touchs the target movie clip(mc2). When mc overlaps the other hitTest is detected.
1. Create buttons(button1 & button2) with display names "hit here" & "press & drag".
2. Then keep these buttons in separate movie clips with instance name (mc1 & mc2).
3. "mc2" is a source to drag to the target "mc1".
4. hitTest is true when "mc2" drag over to "mc1".
mc2.button2.onPress=function(){ // button press function
mc2.startDrag(); // movie clip starts drag
}
mc2.button2.onRelease=function(){ // button release function
mc2.stopDrag();
}
condition=function(){ // this function to is called for detection
if(mc1.hitTest(mc2)==true){ // hit is detected
output="true"; // line is executed if the hitTest is true
}else{
output="false"; // else this line is executed
}
}
setInterval(condition, 10); // function is called for a set of intervals
5. Thanks