I ´ve learned how to do an infinite menu, but for my project, it would be better if the menu stopped at the end instead.
I´ve read about infinite menu on
http://www.kirupa.com/developer/mx/infinite.htm
I´ve searched around kirupa but found nothing.
Any help?
if(yourmc._x <= mcx1) {
yourmc._x = mcx1;
}
if(yourmc._x >= mcx2) {
yourmc._x = mcx2;
}
replace “yourmc” with the instance name of the menu-movieclip. (or deleted it if the code is assigned on the menu itself)
and change mcx1 to the _x position of the menu where you don’t want it to scroll ot the left anymore! |<—
and mcx2 to the _x position of the menu where you don’t want it to scroll to the right anymore! —>|
I inserted the script you provided, but it didn´t work.
I´m using this script on the MC:
onClipEvent (load)
{
xcenter=150;
speed=1/10;
}
onClipEvent (enterFrame)
{
var distance=_root._xmouse-xcenter;
_x+=(distance*speed);
}
Now where should I insert the code you gave me?
put it within he onClipEvent(enterFrame) handlers!
long time no see lost…
i have another alternative for this…
MovieClip.prototype.slideX = function(endPosx) {
this.onEnterFrame = function() {
if (this._x<=endPosx) {
currentPosx = this._x;
diffPosx = endPosx-currentPosx;
movex = diffPosx/3;
this._x = this._x+movex;
if (this._x>=endPosx) {
this._x = endPosx;
this.onEnterFrame = null;
}
}
if (this._x>=endPosx) {
currentPosx = this._x;
diffPosx = endPosx-currentPosx;
movex = diffPosx/3;
this._x = this._x+movex;
if (this._x<=endPosx) {
this._x = endPosx;
this.onEnterFrame = null;
}
}
};
};
that’s for my prototype…
//holder is my MC
var startPos = holder._x;
//rectMask is the maskMC
var d = holder._width-rectMask._width;
var const = d/rectMask._width;
this.onMouseMove = function() {
var endPos = (_xmouse-startPos)*(const);
if (rectMask.hitTest(_xmouse, _ymouse, false)) {
holder.slideX(-endPos+startPos);
}
};
and that is for the action…
hope it helps…
i’ll be gone for a while, so can’t help u after this…
Hi
In the case of an infinite menu. Can I make the xcenter to be widther than just a number? Make it be from 130 to 170 so it´s easier for the user to stop the menu?
The code I´m using is:
onClipEvent (load) {
xcenter = 150;
speed = .3/10;
}
onClipEvent (enterFrame) {
var distance = _root._xmouse-xcenter;
_x += (distancespeed);
}
onClipEvent (load) {
if (_x<=10) {
_x =10;
}
if (_x>=300) {
_x = 300;
}
}
onClipEvent (enterFrame)
{
var distance=_root._xmouse-xcenter;
_x+=(distancespeed);
if (_x > 0) _x=-300;
if (_x < -300) _x=0;
}
thanks