PDA

View Full Version : Only first click registers onPress


plemarquand
09-13-2006, 09:28 PM
Hi,

I am building a numeric stepper (up/down arrows beside a text field) for my site. I am having a very strange problem where if the user clicks the up or down button, the click will register, but any subsequent clicks on the same pixel will not. If the user moves their mouse, they can click again, but as soon as they click on the same spot twice the second click wont register.

The button is in an swf that is contained in a wrapper swf. I'm not sure if this could be an issue in MX2004. Things are called from an onPress() event, but i've tried things using onRelease as well.

Anyone have any ideas? I've been pulling my hair out over this.

sophistikat
09-13-2006, 09:55 PM
Welcome to AS[org] :)
=================

do you have a button handler on the container?
do you have any other buttons with the same instance name?
can we see the code on your button?
can you post a simplified version of your problem?

Rossman
09-14-2006, 09:01 PM
This is a flash focus bug, I've had this before. There is AS code you can put in the onPress, which will refocus flash on that same button, which will work around this issue. I'm not actually sure what causes this to happen, but it's annoying as hell....

This is some code I used to fix this for a button in my project, called "btnUp":

on (press) {
btnUp._focusrect = false;
Selection.setFocus("btnUp");
}

CyanBlue
09-14-2006, 09:18 PM
Howdy and Welcome, plemarquand... :)

Um... I have never heard of such bug, Rossman... Can you create a simple sample that shows me that bug???

I've also attached my version of a quick and cheezy sample... ;)

Oh, I'll take care of that double post stuff...

Rossman
09-14-2006, 09:28 PM
Cyan: I can't generate and FLA that demonstrates this bug, because as I said I don't know exactly what causes it.

All I do know, is that I was working on a project for quite some time, and this bug just starting happening one day with some of the buttons. Searching the net yielded the "refocus" code that I posted above, so other people have definitely also experienced this.

If you got to ElevenStJoseph.com, and go to the View Suites section, that is the page which has the focus issue. btnUp is the button which controls panning the floorplans "down" (the up arrow button on the top of the floorplan viewport)

If I take that code off of btnUp (or btnLeft, btnRight, btnDown), they can't be clicked after the first time you click them, unless you move the mouse cursor.

EDIT: Honestly I believe this is due to the combobox components, I had a lot of weird problems in my FLA after I started using them, and that was just one of them.

CyanBlue
09-14-2006, 09:44 PM
Hm... That's very interesting/weird problem... Well... At least there is a work-around for it... ;)

Hambo
09-15-2006, 09:06 AM
yes, ive had no end of trouble with this.
You simply need a component such as a CopmboBox on the screen with your button. You will find that the button works fine until you click the combobox, then this focus bug rears its head.

The fix seems to be the re-setting of the focus as Rossman suggested.

Rossman
09-15-2006, 01:33 PM
Those components are garbage!

plemarquand
09-20-2006, 06:06 PM
Thank you! this resolved my issue. I've been pulling my hair out for way too long over this silly UI bug.

I have a combobox componant in the form and it is indeed the culprit. Rossman's fix works like a charm! Componants seem so simple but they sure can cause alot of headaches down the road.

Also, thanks for the warm welcome. Judging by the caliber of talent around here I assure you I'll be around more often ;)

pisco
03-15-2007, 06:55 PM
*bows to Rossman*

just saved me from a headache i was starting to have :)

thnx

Claytoon
06-27-2007, 06:08 PM
Man...saved me too. Not sure if this is a flash 6 legacy issue? I see this thread it kinda old...hadn't run into the problem until now (client is requesting Flash 6 plugin requirement) and was kind of stumped to tell you the truth. This solution worked just dandy, so thanks!

schreck425
07-02-2007, 08:26 PM
I have seen that problem before. I'm 99% sure it's a flash bug. It's very difficult to replicate too.

To add another twist in there, we would only see this bug after the swf has played any input box. After an input box appeared, certain buttons wouldn't work anymore. You would need to move the mouse slightly after every click to make the button active again.

I never found a fix for it other than get rid of the input boxes. Luckily I've never seen that problem since on any other projects.

schreck425
07-02-2007, 08:28 PM
my bad, input text, not input box.

Hoogs
04-16-2008, 02:12 AM
2008 and still this bug persists.
It seems to be an inconsistant flash V's browser bug. It always works in the authoring environment and when you open the flash file directly.

I have had the same flash file work fine in FF but not in IE and vice versa. Then to make it more confusing, the browsers which had worked can stop working on the next visit.

I also have a similar problem with onMouse events and FF. One visit the onMouseWheel may work, the next visit it wont register the event at all. In this case it always seems to work in IE.

Hoogs
04-16-2008, 04:51 AM
More testing and I've discovered the same file which works on one server doesnt work on another... The plot thickens.

I dont have access to the settings of either so I cant see what the differences are.

Hoogs
04-16-2008, 05:14 AM
Using setFocus on the press event seems to trigger the release event. So my scroll code wasn't working:
// On the button
on (press) {
scrolling = 1;
scrollUp_btn._focusrect = false;
Selection.setFocus("scrollUp_btn");
}
on (release, dragOut) {
scrolling = 0;
}
// On the frame
onEnterFrame = function () {
my_txt.scroll += scrolling;
};
As soon as you press the button to make scrolling = 1, the release would trigger and make it 0 again :(

I stupidly tried putting the setFocus code on the release event but that created a loop which made the computer unresponsive until the script was aborted.

So I added a check to ensure the loop didn't get started and hey presto!
// On up button
on (press) {
scrolling = -1;
}
on (release, dragOut) {
scrolling = 0;
if (Selection.getFocus() !== scrollUp_btn) {
scrollUp_btn._focusrect = false;
Selection.setFocus("scrollUp_btn");
}
}

// On down button
on (press) {
scrolling = 1;
}
on (release, dragOut) {
scrolling = 0;
if (Selection.getFocus() !== scrollDn_btn) {
scrollDn_btn._focusrect = false;
Selection.setFocus("scrollDn_btn");
}
}