Hello there, this is one of my basic flash beginners tutorials i wanted to attempt but i cannot seem to get it working. I have a movie clip following my mouse at x that slowing eases upto the mouse, Almost like the object is chasing after the mouse along the X axis. I have just one problem. I want that movie clip to attempt to Jump up at the mouse when its on the Y axis, when i left click.
Basically it only needs to try to jump up at the mouse once, only get a certain amount high and then fall back down to the floor and can be repeated once you click again.
EXAMPLE I AM USING
http://www.lionbichstudios.com/flash_tutorials_advanced_onclick.htmlThis code is on the movie clip to follow the X mouse
onClipEvent (load) {
_x = 0;
speed = 8;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
}
I got this from a tutorial
onClipEvent (mouseDown) {
targety = _parent._ymouse;
if (targety<0) {
targety = 0;
} else if (targety>900) {
targety = 900;
}
active = true;
}
onClipEvent (enterFrame) {
if (active) {
xdif = targetx-_x;
_x = _x+xdif/5;
ydif = targety-_y;
_y = _y+ydif/5;
if (Math.abs(xdif)<0.200000 && Math.abs(ydif)<0.200000) {
_x = targetx;
_y = targety;
active = false;
}
}
}
onClipEvent (enterFrame) {
if (active) {
xdif = targetx-_x;
xspeed = xspeed+xdif/10;
xspeed = xspeed*0.800000;
_x = _x+xspeed;
ydif = targety-_y;
yspeed = yspeed+ydif/10;
yspeed = yspeed*0.800000;
_y = _y+yspeed;
if (Math.abs(xspeed)<0.020000 && Math.abs(yspeed)<0.020000) {
delete ("active");
delete ("xspeed");
delete ("yspeed");
delete ("xdif");
delete ("ydif");
}
}
}
onClipEvent (enterFrame) {
if (active) {
xdif = targetx-_x;
_x = _x+xdif/5;
ydif = targety-_y;
_y = _y+ydif/5;
if (Math.abs(xdif)<0.200000 && Math.abs(ydif)<0.200000) {
_x = targetx;
_y = targety;
active = false;
}
}
}
This makes the Object move towards the mouse in the air, but doesnot return to the floor. Anyhelp please? I want to get this in progress Asap! Thanks! I do know that
onClipEvent (mouseDown) {
targety = _parent._ymouse;
if (targety<0) {
targety = 0;
} else if (targety>900) {
targety = 900;
}
active = true;
}
That part of the code when modified can alter the objects movements, would there be anyway to make it reach only a certain set distance up the Y axis and fall back down?