Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Right Mouse on Button

Posted on 2006-03-21
4
Medium Priority
?
179 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.
0
Comment
Question by:COwebmaster
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Montoya
ID: 16253614
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.

0
 

Author Comment

by:COwebmaster
ID: 16253783
Hi Iammontoya. Yes, number 2.  Would you be able to provide an example of how this could be done using hitTest.
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 16254228


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
0
 

Author Comment

by:COwebmaster
ID: 16259468
:-Aneesh, worked great!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question