PDA

View Full Version : quetion regards drag & drop


EricChua
05-06-2004, 03:47 AM
hi, im wondering after successful perform drag and drop, so the objects should be in the dropzone, right? but how can we make the objects no longer draggable after we have drop it in the correct dropzone?

Regards,
Eric

EricChua
05-06-2004, 03:49 AM
my coding:
onClipEvent(load){
origX = this._x;
origY = this._y;
}
onClipEvent(mouseDown){
if(this.hitTest(_root._xmouse, _root._ymouse)){
this.startDrag();
}
}
onClipEvent(mouseUp){
if(this.hitTest(_root._xmouse, _root._ymouse)){
this.stopDrag();
if(_parent.dropZone1.hitTest(this._x, this._y, true)){
this._x = _parent.dropZone1._x;
this._y = _parent.dropZone1._y;
_root.start_button.total++;
}else{
this._x = origX;
this._y = origY;
}
}
}

uten
05-06-2004, 04:10 AM
hi eric,
create a variable that flags whether object is already dropped in the dropzone. i inserted a "dropped" variable.


onClipEvent(load){
origX = this._x;
origY = this._y;
dropped = false;
}
onClipEvent(mouseDown){
if(this.hitTest(_root._xmouse, _root._ymouse) && dropped == false){
this.startDrag();
}
}
onClipEvent(mouseUp){
if(this.hitTest(_root._xmouse, _root._ymouse)){
this.stopDrag();
if(_parent.dropZone1.hitTest(this._x, this._y, true)){
this._x = _parent.dropZone1._x;
this._y = _parent.dropZone1._y;
_root.start_button.total++;
dropped = true;
}else{
this._x = origX;
this._y = origY;
}
}
}

jon

EricChua
05-06-2004, 07:57 AM
thanks dude, you fix my problem