PDA

View Full Version : Mouse Bounds



hagel
July 1st, 2003, 09:10 PM
I currently have a Nav that I am working on that will follow the mouse's _y position. I am wanting to have bounds set that keep the nav in between certain top _y and bottom _y, but am lost on how to do it.

I have tried applying the same techniques that I would to create bounds for a Dragging menu (define top and bottom bounds) but it didn't work with the mouse position.

Here is the code so far that makes the menu follow the mouse:

speed = 25;
menu_mc.onEnterFrame = function () {
target_y = _root._ymouse - this._y;
this._y = this._y + (target_y/speed);
}

Any help would be appreciated.

Thanks,
--
Michael

[m]
July 1st, 2003, 09:24 PM
speed = 25;
menu_mc.onEnterFrame = function () {
tempy = _root._ymouse;
if (tempy > topvalue) tempy = topvalue;
if (tempy < bottomvalue) tempy = bottomvalue;
this._y = (tempy - this._y)/speed;

}

hagel
July 1st, 2003, 09:31 PM
Tried that and now it just stays at the top.

I tried defining a variable

topvalue = 33;
bottomvalue = 663;

But no luck.

Did I do something wrong.

Thanks for the response!

--
Michael

jingman
July 1st, 2003, 10:41 PM
This should certainly get you started.