What you're seeing is a bug in ToggleButtonBar. The mouseDown handler is unnecessarily dispatching a CLICK (the button will shortly after). Your handler got called twice in capture phase and not in bubble or target phase. File a bug if you have time.
Thanks, -Alex ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Clinkinbeard Sent: Wednesday, April 02, 2008 10:03 AM To: [email protected] Subject: Re: [flexcoders] Re: TabContainer with modules - how to cancel Tab change Yep, this was my whole test app. The clicked tab gets traced out twice. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="vertical" creationComplete="init()"> <mx:Script> <![CDATA[ private function init():void { tn.addEventListener( MouseEvent.CLICK, handleClick, true ); } private function handleClick( event:MouseEvent ):void { trace( event.target ); } ]]> </mx:Script> <mx:TabNavigator id="tn" width="400" height="300"> <mx:Canvas label="One" /> <mx:Canvas label="Two" /> <mx:Canvas label="Three" /> </mx:TabNavigator> </mx:Application> On Wed, Apr 2, 2008 at 12:40 PM, Alex Harui <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: Hmm. Capture phase listeners should not get called in bubble phase. Are you sure you didn't also have a non-capture phase listener assigned as well? ________________________________ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of Ben Clinkinbeard Sent: Wednesday, April 02, 2008 6:03 AM To: [email protected] <mailto:[email protected]> Subject: Re: [flexcoders] Re: TabContainer with modules - how to cancel Tab change Alex is, of course, correct. Listening for MouseEvent.CLICK on your TabNav in the capture phase and calling event.stopImmediatePropagation() in the handler will prevent switching to the new tab. (mouseDown didn't seem to work) One thing to remember though is that since you're listening to the capture phase your handler will get called twice for each click. Once during capture phase and again in the bubble phase. HTH, Ben On Wed, Apr 2, 2008 at 12:14 AM, Alex Harui <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: I helped an co-worker block List selection by picking off mouseDown in capture phase and calling stopImmediatePropagation(). You might be able to do the same for TabNav. You might have to get the click event instead and check to see if the target is one of the Tabs. ________________________________ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of ben.clinkinbeard Sent: Tuesday, April 01, 2008 8:08 PM To: [email protected] <mailto:[email protected]> Subject: [flexcoders] Re: TabContainer with modules - how to cancel Tab change Unfortunately, I believe this is the best you can do: http://tech.groups.yahoo.com/group/flexcoders/message/84929 <http://tech.groups.yahoo.com/group/flexcoders/message/84929> HTH, Ben --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "guitarguy555" <[EMAIL PROTECTED]> wrote: > > I have a Flex Application that has a TabNavigator. Each tab contains a > moduleLoader that loads a corresponding Module. > > On some of these modules, I have a basic Form with Validators connected > to it. I want to be able to make sure that the form values are valid > before the user navigates away from the currently selected tab by > clicking a new tab. > > In other words, I want the Validator to fire when the user clicks on a > new tab and if there are any invalid values I want to prompt the user > to fix them and stop the event propogation so the TabNavigator stays on > the current tab. > > How can I cancel the TabNavigator change? >

