1 Reply Latest reply on Apr 24, 2009 8:45 AM by kimvoelcker

    Repeater reference in method call

      Hi,

      I'm trying to reference a value from my repeater component in a method call and it's not working...

       

      <mx:Repeater id="rep" dataProvider="{data.choice}">
                      <mx:VBox>
                             
                              <mx:Image
                              source="{rep.currentItem.image.@src}"
                              toolTip="{rep.currentItem.image.@alt}"
                              mouseDown="dragIt(event, rep.currentItem.price)"
                              />
                 
                     </mx:VBox>
        </mx:Repeater>

       

      The dragIt() function looks like this:

       

      private function dragIt(event:MouseEvent, value:String):void {

      ...

      }

       

      So I want the dragIt() function to get 2 parameters: the event and what is in "rep.currentItem.price"

      The code compiles but then nothing happens and I can't drag the image anymore.

      If I put a string in the method call it works fine...

       

      i.e.

        mouseDown="dragIt(event, "test")"

       

      I also tried

      mouseDown="dragIt(event, rep.currentItem.price as String)"

      same problem

       

      Can anyone help ?

      Is there another way to do this ?

        • 1. Re: Repeater reference in method call
          Level 1

          ok I solved it

           

          you have to use the event targets getRepeaterItem() method

           

          so the correct way to use it is:

           

          <mx:Image
                                  source="{rep.currentItem.image.@src}"
                                  toolTip="{rep.currentItem.image.@alt}"
                                  mouseDown="dragIt(event, event.currentTarget.getRepeaterItem().price)"
                                  />