PDA

View Full Version : TabNavigator


tg
07-20-2006, 06:03 PM
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:

<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,projAddi tions);
btnCancel.addEventListener(MouseEvent.CLICK,cancel Changes);

//tab events
tn.addEventListener(Event.TAB_CHILDREN_CHANGE,tabC licked);

//projData.addEventListener(MouseEvent.CLICK,onProjD ataClick);
//reqData.addEventListener(MouseEvent.CLICK,onProjDa taClick);
//projAnalyst.addEventListener(MouseEvent.CLICK,onPr ojAnalystClick);
//projTime.addEventListener(MouseEvent.CLICK,onProjT imeClick);

//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.

Tink
07-20-2006, 06:57 PM
<?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>

tg
07-20-2006, 07:00 PM
excellent.... tried something similar but didnt work.

will try this know. but i have confidence in your code. tink.

tg
07-20-2006, 07:05 PM
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.