4

I have the following code:

<mx:Repeater id="showNames" dataProvider="{parentApplication.bfa1aStudents}">
    <mx:Text text="{parentApplication.getStudentName(showNames.currentItem)}" color="#8ab534" click="nameSelected(Number(showNames.getRepeaterItem(showNames.currentIndex)));" selectable="false" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" />
</mx:Repeater>

I know you can't use currentItem or currentIndex on a click... and that this problem is fixed with the getRepeaterItem() function, but I'm not sure exactly how to use it. The DP is a bunch of numbers, representing user IDs if that matters. If anybody can help me out with my "click" portion of the text, it'd be greatly appreciated.

Jason Towne
  • 8,014
  • 5
  • 54
  • 69
Brds
  • 1,035
  • 3
  • 17
  • 37
  • 1
    first, you shouldn't use `parentApplication`. It's a horrible practice which couples your view to that application class. Second, why aren't you just using a list if all you're doing is just showing text. – J_A_X Jun 28 '11 at 18:43
  • So how would i reference items and functions that are used on several different layers (parents, children, etc...) throughout the application? – Brds Jun 28 '11 at 21:06

3 Answers3

6

try event.currentTarget.getRepeaterItem() for click instead of showNames

Satish
  • 6,457
  • 8
  • 43
  • 63
2

Try wrapping your Text components in a VBox. Like JAX said, there are some other issues you may want to consider addressing also.

Black Dynamite
  • 4,067
  • 5
  • 40
  • 75
1

Try:

event.currentTarget.selectedItem.data

in your click handler.

Jason Towne
  • 8,014
  • 5
  • 54
  • 69