[Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Paul Steven
I have created a game in AS3 that uses the SPACE bar on the keyboard to
make the character jump. I have encountered a problem whereby pressing the
SPACE bar causes a button on my game screen to be clicked.

I read up that setting buttonMode to false would fix this but it does not
seem to like me using this property on my button.

i.e I tried gameMenuBtn.buttonMode = false;

but here is the error message:

1119: Access of possibly undefined property buttonMode through a reference
with static type flash.display:SimpleButton.

My button is a custom button I have created and not a button from the
components library i.e I just selected a graphic and converted to a symbol
and choose Button.

Any ideas how to prevent this button being clicked by the SPACE bar being
pressed? I could change the key for jumping but feel that the SPACE bar is
the standard one used for this.

Thanks

Paul

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Cor
My guess is that the button has the focus at that particular moment.
So maybe you can set button.mouseEnabled = false;
And set a listener to enable the button on pe. if mouseX and mouseY is at a
specific point.

HTH

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Paul Steven
Sent: woensdag 2 december 2009 10:27
To: 'Flash Coders List'
Subject: [Flashcoders] Prevent space button passing click event to button
(as3)

I have created a game in AS3 that uses the SPACE bar on the keyboard to
make the character jump. I have encountered a problem whereby pressing the
SPACE bar causes a button on my game screen to be clicked.

I read up that setting buttonMode to false would fix this but it does not
seem to like me using this property on my button.

i.e I tried gameMenuBtn.buttonMode = false;

but here is the error message:

1119: Access of possibly undefined property buttonMode through a reference
with static type flash.display:SimpleButton.

My button is a custom button I have created and not a button from the
components library i.e I just selected a graphic and converted to a symbol
and choose Button.

Any ideas how to prevent this button being clicked by the SPACE bar being
pressed? I could change the key for jumping but feel that the SPACE bar is
the standard one used for this.

Thanks

Paul

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.709 / Virus Database: 270.14.89/2539 - Release Date: 12/01/09
20:32:00

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Henrik Andersson
Buttons are meant to be pressed like that. You are using the wrong 
object for the job.


Here is my take on it: you have a game where there are button instances 
in the gui. I would add the keyboard listener to the stage as usual. 
However, in the listener, I would add a condition to ignore events for 
things that actually have a logical response.


if(e.target is TextField||e.target is SimpleButton||(e.target is Sprite 
 Sprite(e.target).buttonMode)) return;

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Paul Steven
Thanks for the replies.

When you say buttons are meant to be pressed like that - do you mean that
it is standard practice to use the tab key to move between buttons and then
use the SPACE key to click it?

You are correct in assuming I have a game where there is a button on the
interface that allows the user to quit the game.

I have the following code on this button:

gameMenuBtn.addEventListener(MouseEvent.CLICK, clickGameMenuButton);

function clickGameMenuButton(event:MouseEvent) {

gotoAndStop(splash);
}

I was hoping there was just a simple way to prevent the SPACE key from
virtually clicking this button. I still want the user to be able to click it
with the mouse.




-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik
Andersson
Sent: 02 December 2009 10:11
To: Flash Coders List
Subject: Re: [Flashcoders] Prevent space button passing click event to
button (as3)

Buttons are meant to be pressed like that. You are using the wrong 
object for the job.

Here is my take on it: you have a game where there are button instances 
in the gui. I would add the keyboard listener to the stage as usual. 
However, in the listener, I would add a condition to ignore events for 
things that actually have a logical response.

if(e.target is TextField||e.target is SimpleButton||(e.target is Sprite 
 Sprite(e.target).buttonMode)) return;
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Henrik Andersson

Paul Steven wrote:

Thanks for the replies.

When you say buttons are meant to be pressed like that - do you mean that
it is standard practice to use the tab key to move between buttons and then
use the SPACE key to click it?


It wasn't implemented just to screw with people. It is how disabled 
people can interact with flash movies.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Prevent space button passing click event to button (as3)

2009-12-02 Thread Paul Steven
Thanks Henrik - yes totally agree that it is a great accessibility feature -
I guess it just tripped me up as this wasn't the case in AS2 as far as I am
aware - think it was the enter button previously?

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Henrik
Andersson
Sent: 02 December 2009 13:36
To: Flash Coders List
Subject: Re: [Flashcoders] Prevent space button passing click event to
button (as3)

Paul Steven wrote:
 Thanks for the replies.

 When you say buttons are meant to be pressed like that - do you mean
that
 it is standard practice to use the tab key to move between buttons and
then
 use the SPACE key to click it?

It wasn't implemented just to screw with people. It is how disabled 
people can interact with flash movies.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders