Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-20-2006, 06:03 PM   #1
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default TabNavigator

ok... playing with the trial of flex builder 2. and so far this seems like its gonna be really really sweet. i am pretty excited.

but i have a quick question about the tabnavigator.

here is my code:
ActionScript Code:
<mx:Script>     <![CDATA[     import mx.controls.Alert;         public function initializeApp():void{         //create necessary listeners         createListener();         //get the project data         disableForm();     }     public function createListener():void {         //button events         btnAdd.addEventListener(MouseEvent.CLICK, projAdditions);         btnEdit.addEventListener(MouseEvent.CLICK,projAdditions);         btnCancel.addEventListener(MouseEvent.CLICK,cancelChanges);                 //tab events         tn.addEventListener(Event.TAB_CHILDREN_CHANGE,tabClicked);         //projData.addEventListener(MouseEvent.CLICK,onProjDataClick);         //reqData.addEventListener(MouseEvent.CLICK,onProjDataClick);         //projAnalyst.addEventListener(MouseEvent.CLICK,onProjAnalystClick);         //projTime.addEventListener(MouseEvent.CLICK,onProjTimeClick);                 //grid events             }     public function tabClicked(e:Event):void{         var i:Number=tn.selectedIndex;         if(i==0 || i==1){             onProjDataClick();         }else if(i==2){             onProjAnalystClick();         }else{             onProjTimeClick();         }     }     public function onProjTimeClick():void{         Alert.show("vew project Time","test");     }     public function onProjAnalystClick():void{         Alert.show("vew project Analysts","test");     }     public function onProjDataClick():void{         Alert.show("vew project data","test");     }    ]]> </mx:Script>         <mx:TabNavigator id="tn" width="100%" height="345" x="2" y="1">             <mx:Canvas label="Project Information" width="100%" height="100%" id="projData"> <suff here/>             </mx:Canvas>             <mx:Canvas label="Project Analysts" width="100%" height="100%" id="projAnalyst"> <stuff here/>             </mx:Canvas>             <mx:Canvas label="Project Work Time" width="100%" height="100%" id="projTime"> <stuff here/>             </mx:Canvas>         </mx:TabNavigator>

ok. just an fyi. all the code works. no errors in fb2, compiles and runs fine.

here is the problem.

i am trying to capture the click event on the TAB. in the tabnavigator.
currently the way i have it set up, it doesnt capture when i click the TAB. it triggers the event when i click into the CONTENT held within the canvas for that tab.

there has to be some hidden event somewhere (or maybe not so hidden -- im new to this). that is triggered so it knows to switch between content in tabs. know what i mean?
i have tried MouseEvent.CLICK and EVENT.TAB_CHILDREN_CHANGE (altho this is not really meant for the tabnavigator i dont think).
both work the same way as mentioned above. but not the way i need them to work.

any suggestions on where to look? or what to try?

appreciate all comments and suggestions. thanks.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 07-20-2006, 06:57 PM   #2
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

	<mx:Script>
		<![CDATA[
			
			private function changeHandler( event:Event ):void
			{
				var tabNavigator:TabNavigator = TabNavigator( event.target );
				trace("Tab changed to: " + tabNavigator.selectedIndex);
			}
		]]>
	</mx:Script>
	
	<mx:TabNavigator id="tn" width="100%" height="345" x="2" y="1" change="changeHandler( event );">
			<mx:Canvas label="Project Information" width="100%" height="100%" id="projData"> 
			</mx:Canvas>
			<mx:Canvas label="Project Analysts" width="100%" height="100%" id="projAnalyst"> 
			</mx:Canvas>
			<mx:Canvas label="Project Work Time" width="100%" height="100%" id="projTime"> 
			</mx:Canvas>
		</mx:TabNavigator>

</mx:Application>
Tink is offline   Reply With Quote
Old 07-20-2006, 07:00 PM   #3
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

excellent.... tried something similar but didnt work.

will try this know. but i have confidence in your code. tink.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 07-20-2006, 07:05 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

ok... needed to edit that.... cause im stupid and cant read.

your code works perfect tink. Thanks....... need to look at correct event.... click != change.

hah!

thanks again.
__________________
tg
---
what the hell was i thinking?

Last edited by tg; 07-20-2006 at 07:11 PM.
tg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:18 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.