Forums > Javascript

Mouse Button Events

September 7, 2008 | 10:28 pm

Hi,

Forgive me if this is a very simple question (which I am sure it is), but I am new to javascript and can’t seem to figure out how to have a mouse click pass a global variable out of a js box outlet.

Basically I am trying to determine which of 2 boxes has been clicked. The rest of it works (I can post my global variable to the max window and see that it changes appropriately upon collision with a box).

What I want is for this to happen upon mouse click, with a ’0′ being nothing clicked, and the boxes as numbered.

I have attached my js file if someone wouldn’t mind having a look.

Cheers

Andy


September 7, 2008 | 10:41 pm

On 8 sept. 08, at 00:28, Andy Brennan wrote:

> Hi,
>
> Forgive me if this is a very simple question (which I am sure it
> is), but I am new to javascript and can’t seem to figure out how to
> have a mouse click pass a global variable out of a js box outlet.
>
> Basically I am trying to determine which of 2 boxes has been
> clicked. The rest of it works (I can post my global variable to the
> max window and see that it changes appropriately upon collision with
> a box).
>
> What I want is for this to happen upon mouse click, with a ’0′ being
> nothing clicked, and the boxes as numbered.
>
> I have attached my js file if someone wouldn’t mind having a look.

when you declare a variable with the var keyword, it’s global to your
js code, but 2 instances of the same js file won’t share the variable.
You should have a look to the Global object for that.

HTH,
ej


Viewing 2 posts - 1 through 2 (of 2 total)