Get the tab index on mouseOver in TabNavigator

78 views
Skip to first unread message

Jagdish

unread,
Mar 11, 2011, 8:54:26 AM3/11/11
to Flex India Community
Hi All,

Can anyone please let me know how to access the tab index in
Tabnavigator on a mouseover Event.

I know we can get it on a ItemCLickEvent with the tab bar selected
index. But how to get it on a mouse over.

Please some one help me out with this as I have been scratching my
head from 2 days.

Thanks in Advance and appreciate your response.


Thanks,
Jagadesh

Venkat Viswanathan

unread,
Mar 11, 2011, 11:07:18 PM3/11/11
to Flex India Community
Hi Jagadesh,

You can use a extended TabNavigator like this:

package components
{
import flash.events.MouseEvent;

import mx.containers.TabNavigator;
import mx.utils.object_proxy;

public class MyTN extends TabNavigator
{
public function MyTN()
{
super();
}

override protected function createChildren():void
{
super.createChildren();
this.tabBar.addEventListener(MouseEvent.MOUSE_OVER,
handleMouseOver);
}

private function handleMouseOver(event:MouseEvent):void
{
var tab:Object = event.target;
var noOfChildren:int = tab.owner.numChildren;
var currentTabIndex:int = -1;
for (var i:int=0; i<noOfChildren; i++)
{
if (tab.owner.getChildAt(i) == tab)
{
currentTabIndex = i;
break;
}
}
if (currentTabIndex>=0)
{
//do your stuff here like throwing an event or something like that
trace(currentTabIndex);
}
}
}
}


Regards,
Venkat
Reply all
Reply to author
Forward
0 new messages