suriaz20
07-13-2007, 02:56 AM
I need your kind help urgently.
I need to create a simple drag and drop game. If the object is dropped to the correct location, the score will be displayed (e.g. 3 out of 4 right!).
I managed to create the drag and drop and snapped it at the right location.
But, am unable to keep and display the score.
I have minimal AS knowledge so the code below was taken from other sites. (I do know the meaning of instance names, and some basic actions though)
Anyone can help?????
-------------------------------------------------------------------------
This is my actionscript applied for the object called "paper" -
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();
}
// see if the dropZone contains the center of this mc
if (_parent.plastic.hitTest(this._x,this._y,true)) {
// center it on the drop zone
this._x = _parent.plastic._x;
this._y = _parent.plastic._y;
// this part here, I did on my own...just an assumption that it might
work but didn't
var total=1;
total++;
score.text="You scored " + total +" out of 4";
}
else {
// return it to its original location
this._x = origX;
this._y = origY;
}
}
I need to create a simple drag and drop game. If the object is dropped to the correct location, the score will be displayed (e.g. 3 out of 4 right!).
I managed to create the drag and drop and snapped it at the right location.
But, am unable to keep and display the score.
I have minimal AS knowledge so the code below was taken from other sites. (I do know the meaning of instance names, and some basic actions though)
Anyone can help?????
-------------------------------------------------------------------------
This is my actionscript applied for the object called "paper" -
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();
}
// see if the dropZone contains the center of this mc
if (_parent.plastic.hitTest(this._x,this._y,true)) {
// center it on the drop zone
this._x = _parent.plastic._x;
this._y = _parent.plastic._y;
// this part here, I did on my own...just an assumption that it might
work but didn't
var total=1;
total++;
score.text="You scored " + total +" out of 4";
}
else {
// return it to its original location
this._x = origX;
this._y = origY;
}
}