Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : [mx] drop an object onto diff. drop locations


shangrula
3/12/2004 9:28:18 PM
Hi

I am trying to make a draggable object have two drop locations, but it will
still only drop to one. Please if anyone can help me or notice my mistake it
would be really appreciated.


on (release) {
if (_root.DragMotor._droptarget == "/Socket1") {
_root.DragMotor._x = _root.Socket1._x;
_root.DragMotor._y = _root.Socket1._y;
_root.CheckMotorDrop();
} else {
_root.MotorDropped = 0;
}
if (_root.DragMotor._droptarget == "/Socket2") {
_root.DragMotor._x = _root.Socket2._x;
_root.DragMotor._y = _root.Socket2._y;
_root.CheckMotorDrop();
} else {
_root.MotorDropped = 0;
}

function CheckMotorDrop () {
//set the speech bubble to give information
_root.txtSpeech = "You have added a motor to the circuit.";
setProperty(_root.DragMotor, _width, 55);
setProperty(_root.DragMotor, _height, 55);
_root.MotorPowered = 1;
_root.DragMotor.play();
_root.MotorDropped = 1;
}


Thanks for your time, Matt.
Jack.
3/12/2004 11:23:10 PM
hope this simple example helps,
3 movieclips, instance names -
trash1
trash2
garbage

this code is on clip - garbage

on(press){
this.startDrag(true);
}

on(release){
stopDrag();
if(eval(this._droptarget) == _parent.trash1){
trace("trash1");
} else if (eval(this._droptarget) == _parent.trash2){
trace("trash2");
} else {
trace("no droptarget");
}
}

/* or use hitTest
on(release){
stopDrag();
if(this.hitTest(_parent.trash1)){
trace("trash1");
} else if(this.hitTest(_parent.trash2)){
trace("trash2");
} else {
trace("no hitTest");
}
}
*/
shangrula
3/13/2004 12:15:25 AM
Hi,

Many thanks for your help, i am very grateful for your help Jack. You have saved me a lot of time.

AddThis Social Bookmark Button