Drag and Drop

I’ve got a drag and drop I set up using this kind of code for each of my draggable items

on (release) {
stopDrag();
if (this._droptarget=="/target1"){
setProperty(this, _x, 213.1);
setProperty(this, _y, 529.5);
} else {
setProperty(this, _x, 579.9);
setProperty(this, _y, 287.5);
}
}

If I want to have an specific action take place after they are all dropped in the correct places how do I do that?

hi coyote!

i´m not sure what you want, but…

try this:

[AS]
on (release) {
stopDrag();
if (eval(this._droptarget) == _root.target1) {
this._x = 213;
this._y = 529;
action1;
action2;
} else {
this._x = 579;
this._y = 287;
}
}
[/AS]

were action1 and 2 are the actions that will happen if this object is droped on the target1.

Sorry it’s so hard for me to explain myself clearly because I’m fairly new at the flash lingo.

:-\ Ok let’s see, I have many objects that are draggable and have to be dropped to one of two boxes.

If they are dropped to the incorrect box they snap back; if the correct box they stay. I need a specific action to take place when ALL of them are dropped correctly. Did that help? Hope so.

:slight_smile:

oh… ok:

lets say you have four objects to be dragged

place this code on the draggable objects:
[AS]
on (release) {
stopDrag();
if (eval(this._droptarget) == _root.target1) {
this._x = 213;
this._y = 529;
_root.draggedOk++;
} else {
this._x = 579;
this._y = 287;
}
}
[/AS]

create a movieclip (blank if you will) and place this code in it:
[AS]
onClipEvent (load) {
_root.draggedOk=0;
}
onClipEvent (enterFrame) {
if (_root.draggedOk>=4){
doThis;
}
}
[/AS]

did you understand it? need explanations?

I think I’ve got it. Let me give it a shot and I’ll let you know.

cool =) let me know the result :wink:

Ok it’s sort of working.
The action I want to happen is for a button to blink so if i set an action to go to a certain frame it will loop until it’s clicked. (and it’s working everywhere else) I just have the action at the end of each movie clip.

It’s going to the frame and stopping instead of playing. So the button turns red but stays that way. Here’s the script on the blank movie clip

onClipEvent (load) {
_root.draggedOK=0;
}
onClipEvent (enterFrame) {
if (_root.draggedOK>=6){
_root.blinkmc.gotoandplay(2)
}
}

whatcha think?

1. dynamic event handler

in the timeline you’d have a script like this

draggedOK = 0;
this.onEnterFrame = function() {
	if (draggedOK >= 6) {
		blinkmc.gotoAndPlay(2);
		delete this.onEnterFrame;
	}
}

2. flag

you can use this one in the movie clip actions

onClipEvent (load) {
	_root.draggedOK = 0;
}
onClipEvent (enterFrame) {
	if (!ok && _root.draggedOK >= 6) {
		_root.blinkmc.gotoAndPlay(2);
		ok = true;
	}
}

yep, kax code is better.
and your mistake was in the …gotoandplay… were should be …gotoAndPlay… :wink:

hey guigo … =)
remember that gotoAndPlay() is not case sensitive …

gotoandplay() works too …
although it’s not a good habit :-\

i guess my point is … it works? yes. but i’m with you, it’s a mistake :wink:

i didn´t knew about that… thanks kax! =)

it´s like i always say: live and read kax´s posts to learn :wink: :stuck_out_tongue:

Originally posted by Guig0
it’s like i always say: live and read kax’s posts to learn :wink: :stuck_out_tongue:

wow! that’s so flattering :beam: :stuck_out_tongue:

:wink: =)

That’s not working. Still just goes to the second frame and stops.

there must be a stop action somewhere at frame 2… ?? :-\

No there’s not. This clip plays at the end of every other movie clip no problem. I don’t get it.

Confused:*(

can you post your fla?

No it’s too big.

:frowning: :frowning:

can you link it to us? :q:

if not, mail it to me: [COLOR=orangered]g u i g 0 _ r j @ y a h o o . c o m . b r [/COLOR]

Originally posted by coyotekel
**No it’s too big.

:frowning: :(**

make a copy of the file and remove everything irrelevant to the problem :wink:

I could email it.