[FMX]i'm stuck - have a problem with a code for navigation

hi,
i built this navigation bar where there is an arrow and menus - when u roll over a menu the arrow slides to it…
now what i’m trying to do is that when u press a menu and then u roll over another menu and when u roll out that menu it slides back to the pressed menu - like a magnet affect…
can anyone help me achieve this affect - all my attempts failed…
here is the fla. it’s in FMX:

u sure its in FMX? coz i get an unexpected error message.

why not use an easing effect that has not only endX but also homeX variables and on rollOut have it slide to homeX but on rollOver have it slide to endX and onPress set homeX to endX…

Prophet.

well thanks for replying…
that is sort of what i did…
anyways here is the code:


mSpeed = 7;
m2Speed = 15;
MovieClip.prototype.mMove = function() {
 if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
  mXTarget = this._x;
  mGo = true;
 }
 _root.mcArrow._x += (mXTarget-_root.mcArrow._x)/m2Speed;
};
MovieClip.prototype.aMove = function() {
 if (mGo) {
  this._x += (mXTarget-this._x)/mSpeed;
  mGo = false;
 }
};
_root.mcArrow.onEnterFrame = function() {
 this.aMove();
};
for (nNum=1; nNum<=50; nNum++) {
 _root["mc"+nNum].onEnterFrame = function() {
  this.mMove();
 };
}

and the arrow has an instance name of mcArrow and all the menus are called mc1 the second mc2 etc etc…
any ideas now?

var mSpeed = 7;
 var mxT;
 MovieClip.prototype.mMove = function(mxTarget) {
     this.onEnterFrame = function() {
         this._x += (mxTarget-this._x)/mSpeed;
         if (Math.abs(mxTarget-this._x)<1) {
             this._x = mxTarget;
             delete this.onEnterFrame;
         }
     };
 };
 for (nNum=1; nNum<=50; nNum++) {
     emc = this["mc"+nNum];
     emc.onRollOver = function() {
         mcArrow.mMove(this._x);
     };
     emc.onRollOut = function() {
         mcArrow.mMove(mxT);
     };
     emc.onPress = function() {
         mxT = this._x;
     };
 }

(like Prophet has said;) )

scotty(-:

wow!!! thanks scotty and u Prophet that’s exactly what i wanted…
buuuut… i have a couple of questions about the code…
one is how do i modify the code so that if i roll out a menu it won’t slide back to 0 x position instead it will stay in the roll overed menu…
and two is why is it that the arrow onLoad slides to 0 x position (i don’t want that)…

var mxT=200;
mcArrow._x = mxT;

Change 200 to the xposition value you want the arrow to start (and to slide to as long you didn’t press one of the mc’s)

scotty(-:

ok never mind i tested it in FMX2004 and it’s ok without assigning a value to mxT…
but i found a problem in the code…
assuming u didn’t press any button yet - if u roll over a menu but then roll out before it get’s to the menu - it get’s stuck in the midlle of it’s motion until u roll over the menu again and it completes it’s motion…
any ideas…?

In the (last) code I gave you, onRollOut mcArrow should ease to 200…

scotty(-:

thanks scotty!!! i got it to work just like i wanted it to…
works great, thanks!

welcome=)