1 Reply Latest reply on Mar 14, 2007 9:28 PM by babo_ya

    Actionscript Function

      I new to flex so I'm still trying to get my head around the concepts. I have created a flex 2 application that uses a repeater to populate radio buttons based on a actionscript array.

      Inside the repeater I am displaying the radio button, on the button I have put a click event to run an actionscript event handler. This works and through the actionscript handler I can change the value of a text field. What I want to be able to do is pass a value from the repeater to the action script handler. In java script I would just have the function name and the value
      i.e. buttonClickHandler(some data); and at the receving end you have function buttonClickHandler(data) {}, and then you just refer to the imported data as 'data' inside the javascript function. With flex the function is defined as
      private function buttonHandler(event:MouseEvent):void.

      Basically I don;t know how to pass data into an event triggers by a mouse event.

        • 1. Actionscript Function
          babo_ya Level 3
          Straightforward, register event and dispatch it from the repeater item.
          <mx:Repeater id="ProductRepeater"

          width="100%" height="100%"


          <v:ProductDetail id="prod"


          productItem="{ProductRepeater.currentItem}" ProductClicked="ProductClickHandler(event);"


          <mx:Spacer width="5%" />


          and here is the handler function

          public function ProductClickHandler(event:ProductEvent):void
          var e:ProductEvent = new ProductEvent(event.product,"ProductClicked");