hi, on http://www.pankpages.com/mainsite.htm, how would you get the arrow to go over the button when your mouse is over the button?
Im a bit tight for time, but this should get you started
build arrow
make arrow MC
the trick is that when your _xmouse,_ymouse comes within range of the buttons (using hittest, for example), the arrow mc _x will be equal to the _xmouse.
That is the crude version and it will just snap to the _xmouse (pretty much)…
to make it ease into it would require a bit more time…
hope it helped a little
OOPS! Didn’t notice that is followed the mouse! Well montoya explained a bit of the techinques I explained the smoothment thingy! The hittest tutorial is loacted here:
http://www.kirupa.com/developer/actionscript/hittest.asp
=)
I’m on a non-flashed computer right now but I hope this works…
Make a button! Make sure the centerpoint of the button is at the center of the button! (not in the corner or…)
Now make the arrow and place it where you want it to be if the mouse is not over some of the buttons!
Right-click the button and choose Actions!
Copy-paste the code given:
on (rollOver) {
_root.btn1over = true;
}
on (rollOut) {
_root.btn1over = false;
}
That just makes a value of a variable become true when you roll over the button and it also makes it become false when you roll out.
note: It’s good to store all the variables to “_root” for easier navigation.
Now right-click the arrow and choose Actions!
now copy-paste the code given:
onClipEvent(load) {
_root.xpos = this._x;
}
onClipEvent(enterFrame) {
if (_root.btn1over) {
this._x += (**btnxpos**-this._x)/3;
} else {
this._x += (_root.xpos-this._x)/3
}
}
NB! Change “btnxpos” to the _x position of the button!
There ya have it!
For multipile buttons you have t change the “btn1over” varfiable for every button (btn1over, btn2over, btn3over)
And that else thingy won’t work either!
You have to add
_root.arrowpos = false;
in the rollOver handler
and
_root.arrowpos = true;
in the rollOut handler
so it would be:
on (rollOver) {
_root.btn1over = true;
_root.arrowpos = false;
}
on (rollOut) {
_root.btn1over = false;
_root.arrowpos = true;
}
and change the actioscript on the arrow to:
onClipEvent(load) {
_root.xpos = this._x;
}
onClipEvent(enterFrame) {
if (_root.btn1over) {
this._x += (**btnxpos**-this._x)/**3**;
}
if(_root.arrowpos) {
this._x += (_root.xpos-this._x)/**3**
}
}
you also have to change “btnxpos” for every button!
Oh Yeah I almost forgot! You can change the “3” in the end of the 2 lines! The higher the number the slower and smoother the movement will be!
note: every variable can be changed to whatever you like. But it has to be changed to the same thing in the places where it is used or the script won’t work!
Well… I hope that Helped!
=)
Thanks Skyo and Iammontoya
with that code, you dont need mine at all.
We should start populating the Best of Kirupa with stuff like this… probably should clean it up just a bit…
And make an example fla…
By the way, did anyone try Syko’s code ?
pom :asian: