Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menu scrolls depending on mouse position 1

Status
Not open for further replies.
Put a movieclip called 'box' on the stage and add this code to frame 1 - the menu you're talking about is basically this several times over...

Code:
//variables
_global.screenHeight = Stage.height;
_global.speed = 20;
//
this.onEnterFrame = function() {
	//move box compared to mouse position
	box.ySpeed = (screenHeight/2-_ymouse)/speed;
	box._y += box.ySpeed;
	//scroll box if it goes off the screen
	if (box._y<0) {
		box._y += screenHeight;
	}
	if (box._y>screenHeight) {
		box._y -= screenHeight;
	}
};[code]
 
thanks a lot,

just one more question:

in the way you solved that issue... doesn't the menue move either when the mouse is not right over it? (that's one thing i'd like to avoid)

thanks

firegambler regards

Firegamler
 
Sorry, I don't exactly follow your question. Do you want the menu to stop moving if the mouse touches it? Then stick the whole script above inside a hitTest condition or you could have it stop when the mouse goes past a certain point like:

//variables
_global.screenHeight = Stage.height;
_global.speed = 20;
//
this.onEnterFrame = function() {
if (_xmouse>100) {
//move box compared to mouse position
box.ySpeed = (screenHeight/2-_ymouse)/speed;
box._y += box.ySpeed;
//scroll box if it goes off the screen
if (box._y<0) {
box._y += screenHeight;
}
if (box._y>screenHeight) {
box._y -= screenHeight;
}
}
};

...which stops the box moving if the mouse is within 100 pixels of the left edge of the screen.
 
thanks a lot for helping me out again!

regards

Firegamler
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top