Movement

Hi,
I made a simple menu and I have 5 links. I also have a semi transparent oval I want to move to the corresponding link on rollover of that link. So far all that I can make work is just jumping the oval to the links. Heres my code:
[AS]
lnk1.onRollOver = function() {
boxa._x = 70;
};
lnk2.onRollOver = function() {
boxa._x = 185;
};
lnk3.onRollOver = function() {
boxa._x = 300;
};
lnk4.onRollOver = function() {
boxa._x = 415;
};
lnk5.onRollOver = function() {
boxa._x = 527;
};
[/AS]

Ive looked at the tutorials and tried to adapt them but pretty much failed miserably.
I can post the .fla if anyone needs more of an explanation.
Any Help is greatly appriciated :beam:

maybe make it _root.boxa._x

and is boxa the instance name or the name of the movie clip? because taht wold make a difference

AHA!!! youre making it a function instead of actually calling it…or did you now post the rest of the code? i would remove the function and just make it

link1.onRollOver{
whatever…
}

juxta-

you mean you want the oval to ease (slide) into position rather than simply jump?

that’s more complicated than simply defining an x coord to your oval on rollover. post your .fla and i’ll get it going for you.

here’s a simple fla i made for you, it should be what you are looking for. the boxa slides to the button only when the mouse is over a button. make sure all your buttons are movie clips as well as boxa. the script uses the same names as you posted earlier so you can probably just copy and paste the AS into the actions layer in the MAIN TIMINE.

here’s the AS:

[AS]numLinks = 5;
boxa._visible = false;
boxa.speed = 4;
sliderMove = function () {
if (this.hitTest(_xmouse, _ymouse)) {
boxa._visible = true;
boxa._x = boxa._x-(boxa._x-this._x)/boxa.speed;
}
};
for (i=1; i<=numLinks; ++i) {
link = “lnk” add i;
_root[link].onEnterFrame = sliderMove;
}
[/AS]

numLinks is how many links there are, boxa initialy is invisible so that it only becomes visible when the mouse moves over a link, and boxa.speed controls the speed of the boxa as it eases towards the button. next the function sliderMove is created which checks if the mouse is over a button and when it is the box eases towards the button using a simple easing script. then a for loop is created to call the loop for each button. this only works if the buttons have names like lnk1 , lnk2 , lnk3 etc… otherwise you’d have to call the function like this :

[AS]home.onEnterFrame = sliderMove;
links.onEnterFrame = sliderMove;
about.onEnterFrame = sliderMove;
//etc…
[/AS]

hope that helps :wink:

  • mike

here’s the fla…

sorry, the other script has a bug in it. when the mouse goes over a button, the box moves towards the button but when the mouse leaves the button halfway thruogh the ease of boxa, then the box stops:(. here’s an updated script :

[AS]numLinks = 5;
boxa._visible = false;
boxa.speed = 8;
sliderMove = function () {
boxa._visible = true;
boxa._x = boxa._x-(boxa._x-newx)/boxa.speed;
};
onEnterFrame = function () {
for (i=1; i<=numLinks; ++i) {
link = “lnk” add i;
if (_root[link].hitTest(_xmouse, _ymouse)) {
newx = _root[link]._x;
_root[link].onEnterFrame = sliderMove;
}
}
};[/AS]

this script makes the boxa go towards the button the mouse was over even if the mouse leaves the button.

here’s the fla…

AH ZYLUM exactly what I want your amazing thanks alot, ive tried long and hard but could never get it right. I was doing a much different way and had trouble with going to the right position.
Thanks to everyone else who posted