1

I've been looking around on how to get the focusedIndex property of a ButtonBar when there's a mouseOver/Out event, but haven't found nothing useful.

Thanks in advance for your help.

Regards,
BS_C3


EDIT 1

Assuming we have this button bar:

buttonbar

I'd like to know, when rolling over, the target button.

Putting a break point in a function that listens to the mouseover event, this is what I see in the debug view:

focusedIndex

As you can see, there's a focusedIndex variable that's is strangely not documented...

BS_C3
  • 385
  • 1
  • 6
  • 23
  • What do you expect a "focusIndex" property to do? What informations hould such a property provide you? Would selectedIndex work? – JeffryHouser Nov 07 '11 at 16:37
  • I'm using a custom tooltip that is launched when the user does a mouse over/out on a button from the buttonbar. While debugging and inspecting the variables of the mouseOver event, I found that there was a variable called "focusedIndex"... Knowing the index would help me retrieve the data I need from the dataprovider of the buttonbar. – BS_C3 Nov 08 '11 at 08:56
  • There is no documented property named focusedIndex in the MouseEvent class: https://www.flextras.com/MobileComponents/Samples/SquareButtonSample/ . Do you want to know which button the mouse cursor is over? – JeffryHouser Nov 08 '11 at 13:25
  • That's indeed what I'd like to know... However, the buttonbar does not receive the same data as a simple button... >.< I just added a EDIT 1 where you can see the focusedIndex I'm talking about. I know it's not documented... which surprised me cause I'm seing it in my debug view... – BS_C3 Nov 08 '11 at 15:20

1 Answers1

1

The value is an mx_internal value.

Just use this magic when yo do imports:

import mx.core.mx_internal;
use namespace mx_internal;

Then you should be able to access the value in your button bar's mouse hander w/o issues:

trace(e.target.focusedIndex);

As a point of clarification; the property on the ButtonBar class; not on the event class, like you originally stated. The ButtonBar instance is embedded inside the Mouse Event. I've heard that called Nested Objects before.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59
  • Hi! This works great! The next issue I'm having is that I cannot use 'use namespace mx_internal' cause I'm using the StyleManager to set styles. So I'm getting the error "1000: Ambiguous reference to setStyle". I tried some tricks (http://sherifabdou.com/2008/09/1000-ambiguous-reference-to-setstyle/) but cannot make it work. Would you have any clue? Thanks :) – BS_C3 Nov 09 '11 at 09:23
  • If there is an ambiguous reference; you have to solve it by fully classifying the class name before the method call; and possibly specifying the namespace for the mx_internal namespaces. I think you can probably removed the "use" command and replace the trace with e.target.mx_internal::focusedIndex or something similar. I forget the exact syntax off top of my head. You'd need to provide more code to get a more concrete answer. – JeffryHouser Nov 09 '11 at 12:28
  • Well, I finally stopped using the StyleManager... I tried to use e.target.mx_internal::focusedIndex but that did not work... :( Thanks for all your answers and help :) – BS_C3 Nov 09 '11 at 14:09
  • I must have the syntax wrong on that. Glad it helped, though. – JeffryHouser Nov 09 '11 at 14:42
  • Your syntax is not wrong... I saw the same syntax in quite some places... but it just did not work >. – BS_C3 Nov 09 '11 at 17:43