Welcome, Guest
  • Author Topic: STOP the classic Slider Menu, when mouse leaves area  (Read 1957 times)

    Alex

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Does anyone know the ActionScripting to Stop a Classic Slider Menu when your mouse leaves the area where that Slider Menu rests?

    To give a little more specifics, hopefully that won't confuse you:

    My slider menu (mc1) sits on top of another Movie Clip (mc2). MC2 is on the main stage, and only takes up a quater of the bottom left hand corner. Unfortunately, if you move your mouse to select a button which is not on the Slider Menu but somewhere else on the screen,  the slider continues to, well, slide.

    I'm kind of new to AS, so be gentle. Thanks.

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:STOP the classic Slider Menu, when mouse leaves area
    « Reply #1 on: 05/20/03, 02:46 »
    If the slider react to an on(rollOver), then you need to add a on(rollOut) to disable it, and the same with the others events like press - release. So look in your scrollbar and check to which event is reacting your button (or sensible area)

    Jorge

    Alex

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Actually, this is the code I'm using
    « Reply #2 on: 05/20/03, 08:29 »
    Jorge, this is the code that I am using for the sliding menu:

    onClipEvent (load)
    {
       xcenter=92;
       speed=1/10;
       }
    onClipEvent (enterFrame)
    {
       var distance=_root._xmouse-xcenter;
       _x+=(distance*speed);
       if (_x > 0) _x=0;
       if (_x < -567) _x=-567;
    }


    //the xcenter is not exactly the center becuase there is a mask applied to reveal only the left side of the slider menu

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:STOP the classic Slider Menu, when mouse leaves area
    « Reply #3 on: 05/20/03, 09:06 »
    You need to add a sensible area that triggers your event, since on(enterFrame) is constantly working without regarding what happens on stage. So you can i.e use an invisible button covering the area you want to use (the area that reacts to mouse) and put in the button a flag

    [script]
    //In invisible button
    on(rollOver){
     draging = true
    }
    on(rollOut){
     draging = false
    }

    //Modify a little this
    onClipEvent (enterFrame){
     if(draging==true){ //Checks if mouse is over the sensible area
       var distance=_root._xmouse-xcenter;
       _x+=(distance*speed);
       if (_x > 0) _x=0;
       if (_x < -567) _x=-567;
     }
    }
    [/script]

    If you don't want the hand cursor in the sensible area, then perhaps could use a hitTest over a coordinate of stage (see hitTest entry in ActionScript dictionary) following the same idea

    Jorge


    Alex

    • Server what's that
    • *
    • Posts: 4
      • View Profile
      • Email
    Re:STOP the classic Slider Menu, when mouse leaves area
    « Reply #4 on: 05/20/03, 09:28 »
    very very cool, thanks Jorge!