PDA

View Full Version : Need help with clicking a movieclip



Sammo
January 8th, 2005, 06:28 AM
I am building a game that has a power bar and an angle meter. Both, the user sets.
The power bar works fine (so does the angle meter) except for the fact that it moves whereever the mouse is clicked.

with this code:

onClipEvent (load) {
_x = 500;
_y = 250;
scrollerClicked = false;
}
onClipEvent (mouseDown) {
scrollerClicked = true;
}
onClipEvent (mouseUp) {
scrollerClicked = false;
}
onClipEvent (enterFrame) {
if (scrollerClicked) {
endY = _root._ymouse;
_y += endY-_y;
if (_y < 160) {
_y = 160;
} else if (_y > 340) {
_y = 340;
}
}
}

Is there a way to make the scrollerClicked variable only true when the actual movieclip is clicked, not anywhere on the stage?

PCGamre
January 10th, 2005, 07:09 PM
Shouldn't that be:


onClipEvent (enterFrame) {
if (scrollerClicked==true) {
endY = _root._ymouse;
_y += endY-_y;
if (_y < 160) {
_y = 160;
} else if (_y > 340) {
_y = 340;
}
}
}

mixedtrigeno
January 11th, 2005, 04:18 PM
onClipEvent (load) {
_x = 500;
_y = 250;
endY = _root._ymouse;
}
onClipEvent (enterFrame) {
if (this.hitTest(_xmouse, _ymouse)) {
// i have no idea what u trying to do here
// first are u trying to say that the mc's y position
// is equal to 250 pixels?
// _y += endY-_y;
// if so i think thats how u do it that's saying to
// to move the mouse 250 pixels up if not leave the way
// you have it i could be mistaken. I DON'T KNOW WHAT U SAYING THERE
endY += _y;
}
if (this._y >= 160) {
this._y = 160;
}else
if (this._y >= 340) {
this._y = 340;
}
}



i believe thats the way to do it to eliminate having so many enterFrames which will slow down your game a lot. i am sure what you trying to do but i hope that helps you a lil
NOTE: am not expert.