Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

click and drag collision detection 1

Status
Not open for further replies.

Flashoid

Technical User
Dec 11, 2002
163
US
Does anyone have an easy to edit movie which does this: You would have one object you drag over a hotspot(or into another object) and it moves the overall movie playhead to the next frame -- that's all it needs to do. I have tried several on (dragOver) related files on the web with no success.

thanks
 
If the objects are movieclips (and most things can be converted to movieclips) then you can use hitTest() to detect collisions. Add this code to frame 1 of an new movie and you should be able to adapt it to what you need:

Code:
this.onEnterFrame = function() {
	if (clip1.hitTest(clip2)) {
		trace('COLLISION');
	}
};
//
this.createEmptyMovieClip('clip1', 20);
this.createEmptyMovieClip('clip2', 10);
clip1.beginFill('0xff0000');
clip1.moveTo(0, 0);
clip1.lineTo(30, 15);
clip1.lineTo(0, 30);
clip1.endFill();
clip2.beginFill('0x0000ff');
clip2.moveTo(100, 0);
clip2.lineTo(130, 15);
clip2.lineTo(100, 30);
clip2.endFill();
clip1.startDrag(true);
//
stop();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top