PDA

View Full Version : Glide to mouse position - sliding movieclip nav


Jon B
09-18-2003, 11:39 AM
Hi,

I've been trying to create a sliding nav like on www.tigerofsweden.com - now I have used some scripts from similar demos but I can't figure out how to stop the nav from sliding outside of the page. Basically I want it stop just before it reaches the edge.

I have included an example - it was done using flash mx 2004 and so I have only been able to save it at a minimum of flash mx - sorry to you flash 5 guys.

Please help if you can, I'm really short on time with this one.

Thanks guys,

Jon

McGiver
09-18-2003, 01:54 PM
I think the eayiest way is to use the following code for your slidemenu
onClipEvent (load) {
var miny = 10;
var maxy = 509;
}
onClipEvent (enterFrame) {
if (top.bew == "on" && (_ymouse<-31 || _ymouse>31)) {
diffY = _root._ymouse-_y;
_y += diffY/40
if (miny>=(_y-_height/2)) {
_y = miny+_height/2+0.05;
} else if (maxy<=(_y+_height/2)) {
_y = maxy-_height/2-0.05;
}
}
}

Jon B
09-18-2003, 01:59 PM
thanks buddy - right on the money and just in time - too cool.

If you can think of any improvements then please suggest those too - The code is based on a menu thing from the movies section of this site - something done by flashstar.de - trouble is that guy is german and I don't understand much of his site - but I'm bad with AS anyhow so it probab;y wouldn't have helped.

Thanks again mate.

Jon

McGiver
09-18-2003, 02:12 PM
hmm, maybe you use speed for a more liquid acceleration!
something like
yspeed= (yspeed+diffY/60)*10/8
_y +=yspeed

(maybe you add some math, that slows the menu down on the upper and the lower edge)

if you got some words in german you don't understand:
i am german and probably abled to translate them (please no complete page :D )

Jon B
09-18-2003, 04:29 PM
sounds cool, I'm bad at this sort of math, I was ok at school math, but this stuff seems to be so weird. I guess it has more physics type stuff in it.

anything that could make it better tho.

actually is there any way to cut down on the amount of nested movieclips?