tag:blogger.com,1999:blog-834293513622460372.post1934676798346286081..comments2023-09-02T08:38:41.945-03:00Comments on What's My Title Today?: Flex TabNavigator - tab click event?Angelahttp://www.blogger.com/profile/10242843268874466256noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-834293513622460372.post-65039654464822432812015-09-23T13:18:18.731-03:002015-09-23T13:18:18.731-03:00To find out which tab was clicked, add an ID to ea...To find out which tab was clicked, add an ID to each button:<br /><br /> for (var i:int=0; i<tabNav.getChildren().length; i++)<br /> {<br /> var tb:Button = tabNav.getTabAt(i);<br /> tb.id = "tb" + i.toString();<br /> tb.addEventListener(FlexEvent.BUTTON_DOWN, OnTabClick);<br /> }<br /><br />and then<br /><br /> private function OnTabClick(e:FlexEvent):void<br /> {<br /> <br /> var s:String = e.currentTarget.toString();<br /> var lastPoint:int = s.lastIndexOf(".");<br /> var tabId:String = s.substr(lastPoint + 1);<br /> Alert.show(tabId + " Click!!"); // or whatever you want<br /><br /> }<br />George Lnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-61949528697199412552014-01-07T15:57:54.841-04:002014-01-07T15:57:54.841-04:00This post is still relevant in 2014!
Thanks Ang &...This post is still relevant in 2014!<br /><br />Thanks Ang & Thanks Duckduckgo.com :PAnonymoushttps://www.blogger.com/profile/02499111261898965091noreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-13908475013764060862012-03-21T13:34:04.880-03:002012-03-21T13:34:04.880-03:00import mx.controls.Button;
import mx.events.F...import mx.controls.Button;<br /> import mx.events.FlexEvent;<br /> private function init():void {<br /> for (var i:int=0; i<tabNav.getChildren().length; i++) <br /> { <br /> var tab:Button = tabNav.getTabAt(i); <br /> tab.addEventListener(FlexEvent.BUTTON_DOWN,tabClickHandler); <br /> } <br /> }<br /> private function onClickTab(event:Event):void {<br /> tw.title="onClickTab:"+event.target;<br /> }<br /> private function tabClickHandler(event:FlexEvent):void {<br /> for (var i:int=0; i<tabNav.getChildren().length; i++) <br /> { <br /> if (event.target == tabNav.getTabAt(i)) {<br /> var child:Object = tabNav.getChildAt(i);<br /> child.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); <br /> break;<br /> }<br /> } <br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-44657668365611863042012-03-21T13:27:26.845-03:002012-03-21T13:27:26.845-03:00Thanks for the hint. I would like to share test ex...Thanks for the hint. I would like to share test example that I have been working with. I hope that it fills in the gaps that others may have.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-31539008179936071652011-08-05T12:13:54.203-03:002011-08-05T12:13:54.203-03:00you can use, TabNavigator's change eventyou can use, TabNavigator's change eventAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-90065179950033109512011-06-27T16:17:28.898-03:002011-06-27T16:17:28.898-03:00The solution presented at the link I have below wa...The solution presented at the link I have below was incredibly useful for me.<br /><br />You directly place a listener on the tabnavigator, but specify onCapture=true. This way, you get the event BEFORE the underlying navbar has a chance to stopImmediatePropagation. If you want to wait until after the switch, you can use callLater, but this allows you to grab that silly cancelled mouse click event. (Even works on disabled tabs, this was an advantage for me, may be an unwanted side-effect for you)<br /><br />http://natescodevault.com/2008/09/30/preventing-the-tabnavigator-from-changing-tabs-when-one-is-clicked/Samnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-63872113911547662912011-06-27T02:01:20.623-03:002011-06-27T02:01:20.623-03:00Very useful, thank you.Very useful, thank you.Kieran Dang 鄧英武https://www.blogger.com/profile/16721379474740012947noreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-54924049683860670472010-08-17T03:52:57.842-03:002010-08-17T03:52:57.842-03:00Excellent Detective work :) You saved me hours of ...Excellent Detective work :) You saved me hours of frustration. CheersAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-2235013668801795772009-08-25T12:21:33.275-03:002009-08-25T12:21:33.275-03:00Hey, Thanks a lot...
Saved me a lot of time...Hey, Thanks a lot...<br />Saved me a lot of time...Dipanjanhttp://flexblockers.blogspot.com/noreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-29807867278915626812009-08-04T18:33:38.347-03:002009-08-04T18:33:38.347-03:00I was having a tough time figuring out why there w...I was having a tough time figuring out why there was no click event on the tab itself. Your code saved the day.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-65357480146347111182009-07-27T20:52:39.935-03:002009-07-27T20:52:39.935-03:00hey nice! thanks ;)hey nice! thanks ;)Unknownhttps://www.blogger.com/profile/01517975050197968520noreply@blogger.comtag:blogger.com,1999:blog-834293513622460372.post-6027715826906160142009-07-08T13:20:52.018-03:002009-07-08T13:20:52.018-03:00Thanks. I was looking for this.
One question I h...Thanks. I was looking for this. <br /><br />One question I had was why the need to use FlexEvent.BUTTON_DOWN instead of the usual MouseEvent.CLICK. Turns out the clickHandler function in TabBar.as in the Flex framework has an event.stopImmediatePropagation();Jamie McDanielhttp://www.curiousfind.comnoreply@blogger.com