Groups | Blog | Home
all groups > flash actionscript > april 2005 >

flash actionscript : Draggable Mc's


tozzy2
4/9/2005 12:00:00 AM
Hello. I have a matching game with some drag and drop clips. When all the
mc's are matched up correctly, the movie goes to the next frame where there is
a play again button. When this button is clicked the movie returns to the
first frame. The actionsript on this button , I set the set up the properties
so that the movie clips return to their origingal positions. The problem is
that the clips are no longer draggable. And ideas how to fix this?
Here is the code from one of the clips.

onClipEvent (load) {
white_x = getProperty(this, _x);
white_y = getProperty(this, _y);
}
onClipEvent (enterFrame) {
this.onRelease = function() {
_root.tries++;
if (hitTest(_root.answer2)) {
_root.answer2;
setProperty(this, _x, white_x);
setProperty(this, _y, white_y);

this._x = _parent.answer2._x;
this._y = _parent.answer2._y;


_root.s_check._visible = true;
_root.score++;
this.enabled = false;
} else {
setProperty(this, _x, white_x);
setProperty(this, _y, white_y);
}

};
}
on (press) {
this.startDrag();
}
on (release) {
this.stopDrag();
}
Boonana
4/9/2005 12:00:00 AM
Boonana
4/9/2005 12:00:00 AM
when you win call it 'win' and then in the main timeline say

if (win){
//all buttons are enabled
gotoAndStop(1);
Boonana
4/9/2005 12:00:00 AM
i think the problem is that after you go to frame one, when the clip loads, hitTest(_root.answer2) is still true, and the _x and _y properties are set to white_x and white_y.
tozzy2
4/9/2005 8:37:23 PM
Thanks! Im still unclear though how to enable them again(make the clips
draggable) and also reset the game. I have this code on the first frame of the
main timeline:
stop ();

this.onEnterFrame = function() {
if (_root.score == 8) {
delete(this.onEnterFrame);
gotoAndStop(2);
}
};

Thanks again.
tozzy2
4/10/2005 12:00:00 AM
AddThis Social Bookmark Button