We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Right Mouse on Button

COwebmaster
COwebmaster asked
on
Medium Priority
204 Views
Last Modified: 2010-04-03
Ok, I found this great script on using the right mouse:

function rMouseDown() {
        if(Key.isDown(2)){
                clearInterval(rMouseListen);
                rMouseListen = setInterval(rMouseUp, 40, mc);
                trace("right mouse down");
                        
        }
}
function rMouseUp(mc:MovieClip) {
        if(!Key.isDown(2)){
                clearInterval(rMouseListen);
                rMouseListen = setInterval(rMouseDown, 40);
                trace("right mouse up");
                        
        }
}
rMouseListen = setInterval(rMouseDown, 40);


How can it be used though on a button so only if you right-mouse click on the button that it works.  So it shouldn't work if the mouse is off the button.
Comment
Watch Question

MontoyaProcess Improvement Mgr
CERTIFIED EXPERT

Commented:
so you want to eliminate left click functionality? Is that what you mean?

or do you mean.. how do you make sure it works when its within a particular button?

If it's number two, you can do a hitTest with an IF statement, and that should cover that.
If it's number one, then don't do any onRelease statements, and you should be fine.

COwebmasterWeb Manager

Author

Commented:
Hi Iammontoya. Yes, number 2.  Would you be able to provide an example of how this could be done using hitTest.
CERTIFIED EXPERT
Top Expert 2008
Commented:


1.
Create a MovieClip (not button) on root with instance name "btn"

2.
and put this code on first frame...
-------------
function rMouseDown()
{
      if (Key.isDown(2) && _root.btn.hitTest(_root._xmouse,_root._ymouse))
      {
            clearInterval(rMouseListen);
            rMouseListen = setInterval(rMouseUp, 40);
            trace("right mouse down on btn");
      }
}
function rMouseUp()
{
      if (!Key.isDown(2))
      {
            clearInterval(rMouseListen);
            rMouseListen = setInterval(rMouseDown, 40);
            trace("right mouse up");
      }
}
rMouseListen = setInterval(rMouseDown, 40);
-----------

3.
Compile (press CTRL+ENTER) to test it

:-Aneesh

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
COwebmasterWeb Manager

Author

Commented:
:-Aneesh, worked great!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.