I have a movieclip on the stage with an onPress event handler and a mouse event listener applied to the movie. It works just fine until I drop a TextArea component on the stage.
I put this example together to show the problem:
When I drop the TextArea on the stage and the client types something in one of the TextAreas then the button events aren’t properly firing. The example has several extra text fields on the stage, but the problem shows up even if it’s just the single TextArea and the button (and I trace the output).
Also.. if I comment out the mouse listener and have _only_ the myButton.onPress event handler then the button still doesn’t work all the time. I just added the listener to show that the button is getting pressed and something is registering it.
Someone on Flashcoders noticed that the problem only occurs if you hold the mouse still and click repeatedly. If you move the mouse and click then it works.
(update 5/15/04) - I should have noted that I don’t see this problem if I use myBtn.onMouseDown There was a reason why I couldn’t use onMouseDown and was trying to use onPress, but at the moment I can’t remember what the reason was.
21 Mar 2004 at 08:45 pm | #
(update) I spoke to someone on the Flash development team while I was at FlashForward and they are aware of this bug.. so maybe it will be fixed soon..
21 Apr 2004 at 02:30 pm | #
Has there been any resolution to this issue ? workarounds ? suggestions ...
I have the additional problem, that, when I load a swf containing a textArea into another "holder" mc , a problem becomes evident when the user mouse clicks on the scrollbar of the textArea swf , that results in all the text in the textArea becoming selected, as well as the textArea portion becoming highlighted by a green or yellow border.
Anybody know of a fix for this ?
Thx
07 May 2004 at 10:02 am | #
I've noticed similar issues with some Dbl click code that used to work in MX but in MX 2004 is starting to work hit and miss. I've also seen in some cases a onRelease trigger a onRollout to. Hope they fix this soon. Thanks for documenting it.
07 May 2004 at 02:07 pm | #
I discovered another issue...I have two Button components in the same Movieclip as a TextArea (all are created dynamically via ActionScript). I'm still trying to narrow down the specifics, but I can create the situation where typing text in TextArea causes the clickevent listener on the buttons to fire.
15 May 2004 at 04:43 pm | #
Mark S. sent me this code and says the problem is that the text area never releases focus. He noticed that the cursor continued to blink in the textarea even after he pressed the button.. i.e. the textarea continues to grab focus.
Code:
----------------------------
/*
On the button you want to set the _focusrect to false
so you don't end up with a yellow box around your button.
After that you want to set the Selection to the button so its
not on the text area/field or otherwise.
*/
your_btn.onRelease = function() {
this._focusrect = false;
Selection.setFocus(this);
//do whatever your button was doing
}
------------------------
which looks like it would work, but I'm not too sure how this would affect 508 compliance (since you're hiding the yellow box that indicates the button has focus).
it definitely helps though..
02 Feb 2005 at 02:32 pm | #
SOLUTION FOR TEXTAREA COMPONENT'S TEXT SELECTED ISSUE:
var scrollerCP:mx.controls.TextArea;
someListener2 = new Object();
someListener2.focusIn = function() {
Selection.setFocus("focus_holder");
};
scrollerCP.addEventListener("focusIn", someListener2);
I have a Input Textfield that I called "focus_holder", but I'm guessing it can be another component such as a Radio Button. Basically redirecting the focus on another instance when the TextArea component is focused.
WHAT A PAIN it was!!! Hope this helps some people.
27 Apr 2005 at 11:56 am | #
You actually don't need a focus holder component - even a movie clip will work. Anything to get the focus off of the textarea (or in my case, textinput) component.
15 Jun 2006 at 11:56 pm | #
I tried doing it this way, which seems to be essentially the same thing, but its not working. Why?
Text_txt.onSetFocus = Refocus;
//redirect focus
Refocus = function(){
trace("REFOCUS");
Selection.setFocus("localRoot.focusHolder_txt");
}
11 Apr 2007 at 01:33 pm | #
Note that the event messes up only when the mouse does not move on the button.
1. Click in the text area.
2.Click the button and dont move the mouse
3.Repeat step 2 about 5 times.
4.Move the mouse over the button and click one.
5.Move the mouse again and click the button.
The events unwind differently.
12 Apr 2007 at 04:45 pm | #
unreal. I just spent hours fixing this bug. Finally figured it out, and on(press) I put the focus on the button being clicked and remove it from the text input field. Then I see this terrible yellow border on the button. So I searched in google for "Flash Yellow Border BUtton Focus" and this is the first link that comes up. I searched all day and found ZERO information on this until now, after I fixed it. Just thought I'd share that.
Still good that I found this though, as Mike posted above roughly 2 years ago, the _focusrect property is what I needed.
To the above poster, on press just add in Selection.setFocus(Some other Movie Clip); and you'll be good to go.
15 Apr 2007 at 10:12 am | #
I just had a issue with it dropping keystrokes to. - Built what I thought would be a quick contact form using (2) TextInput components and a TextArea component and a send button, and now as you type it drops a keystroke every 5 seconds roughly.
I type bad as it is so dropping letters and spaces is kinda trippy.
15 Apr 2007 at 02:19 pm | #
Update: This issue I'm having only effects Vista / IE7.
I'm also noticing other strange behaviors so I hope they get them worked out before a lot more ppl run into them.
04 Dec 2007 at 08:12 pm | #
Thanks for this! I've been wondering how to fix this.... and I someone finally came across your post... kudos!