PDA

View Full Version : Simple drag'n'drop: improved problem description


chronicsmoke
11-02-2002, 03:11 PM
Hi,

okay...the problem: write an Actionscript that tells a movie to jump to frame 3 if two (or more) movieclips are dragged AND RELEASED over a certain target area.

I got two MC in my movie with the following Actionscript on each of them (except different instance names off course):

on (press) {
startDrag(getProperty(_x, _y));
}
on (release) {
stopDrag();
if (_droptarget == "/hitarea01") {
nextFrame();
} else {
setProperty("", _y, OrgY);
setProperty("", _x, OrgX);
}
}


In the "actions"-layer of the main timeline, I've got a nested if-statement that checks if both MC are dragged over the hitareas. I used this code:

if (circle01.hitTest(hitarea01)) {
if (circle02.hitTest(hitarea02)) {
gotoAndPlay(3);
}
}


On frame 3, I've put a message that both MCs were dragged over the correct target areas.

It works. Anyway, I don't want the movie to jump if both MCs are dragged but if the user releases the mouse button. I've tried to use the _droptarget-property but it just doesn't work well...

In order to get a clue of what I've meant, I attached my *.fla to this post.

Any tips would be helpful.

Thanx.

Billy T
11-03-2002, 02:54 PM
set a var when dropped on the target

then check this var from the main timeline

see attached

cheers

chronicsmoke
11-04-2002, 09:04 AM
Yes, that's the solution I've been looking for.

Matter of fact, I tested this kind of approach also but it seems that I've made a mistake in my syntax and so it didn't work.

Thanks again.