![]() |
![]() |
||||||
|
|||||||
| Tags: selectedindex, tabnavigator, working |
![]() |
|
|||
|
I have reduced a problem I'm having to a very simple example. I'm using the
routine in a validation of form, trying to make sure they don't leave the current tab index if a form is 'open.' It works the first time but after that, does not work every other time. Suggestions? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; private function resetTab():void{ tabNav.selectedIndex = 0; Alert.show("selected child should be tab1 but it's " + tabNav.selectedChild); } ]]> </mx:Script> <mx:TabNavigator id="tabNav" x="48" y="35" width="200" height="200" change="resetTab();"> <mx:Canvas label="Tab 1" width="100%" height="100%" id="tab1"> </mx:Canvas> <mx:Canvas label="Tab 2" width="100%" height="100%" id="tab2"> </mx:Canvas> </mx:TabNavigator> </mx:Application> |
| Sponsored Links |
|
|||
|
On Jun 3, 1:37 am, "John Hall" <webforumsu...@macromedia.com> wrote:
> I have reduced a problem I'm having to a very simple example. I'm using the > routine in a validation of form, trying to make sure they don't leave the > current tab index if a form is 'open.' It works the first time but after that, > does not work every other time. Suggestions? > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> > <mx:Script> > <![CDATA[ > import mx.controls.Alert; > private function resetTab():void{ > tabNav.selectedIndex= 0; > Alert.show("selected child should be tab1 but it's " + > tabNav.selectedChild); > } > ]]> > </mx:Script> > <mx:TabNavigatorid="tabNav" x="48" y="35" width="200" height="200" > change="resetTab();"> > <mx:Canvas label="Tab 1" width="100%" height="100%" id="tab1"> > </mx:Canvas> > <mx:Canvas label="Tab 2" width="100%" height="100%" id="tab2"> > </mx:Canvas> > </mx:TabNavigator> > </mx:Application> I'm having the same issue and have yet to find a solution. It is slightly comforting to see that I'm not alone in my frustration. |
|
|||
|
me having same problems just wasted 5 hours yesterday on this issue.........use
the validateProperties()..........the logic behind it might be that tabNaigator object has a property selectedIndex which is forcefully committed by this function |
|
|||
|
I ran into a similar problem where the correct tab was not always being
selected when the ViewStack selectedIndex changed. This is a bug in Flex, which I have reported and submitted a patch for. In the meantime, you can use the attached Custom Class, and this should fix your problem.... package { //-------------------------------------------------------------------------- // // Import all necessary classes // //-------------------------------------------------------------------------- //---------------------------------- // Import necessary non-core Flex classes //---------------------------------- import mx.containers.TabNavigator; public class CustomTabNavigator extends TabNavigator { //-------------------------------------------------------------------------- // // Methods // //-------------------------------------------------------------------------- // Constructor public function CustomTabNavigator() { super(); } override protected function commitSelectedIndex(newIndex:int):void { super.commitSelectedIndex(newIndex); // Select the corresponding Tab in the Tab Bar (this fixes a bug in Flex) tabBar.selectedIndex = newIndex; } } } |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise