0 Replies Latest reply on Jul 10, 2011 6:09 PM by Cancerinform

    Eventhandler association with Arraycollection problem using DataGroup

    Cancerinform Level 2

      I am using the DataGroup (similar to Repeater) and get the data from an XML file that fills an Arraycollection. The DataGroup requires an ItemRenderer that consists of labels and Image components surrounded by Canvas. The text, images x and y parameters from individual items from the XML file are all correctly accepted by the ItemRenderer. However, I have some mouse eventhandlers incorporated in the ItemRenderer but only the last item from the Arraycollection receives the eventhandlers. I want of course all items to receive mouse events.


      So what am I doing wrong? I know all very well in Flash, which is my background but this type of problem not in Flash builder. Here is the code for the ItemRenderer:


      <?xml version="1.0" encoding="utf-8"?>
      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
          <mx:Canvas width="275"  height="90" backgroundColor="#cccccc"
                     y="{data.y}" x="{data.x}" mouseDown="mouseDownHandler(event)"
                     mouseUp="mouseUpHandler(event)" click="canvas1_clickHandler(event)"
                     borderStyle="outset" borderThickness="5">
              <mx:Canvas id="innerCanvas" width="100%" height="100%">
                      protected function mouseDownHandler(event:MouseEvent):void
                          innerCanvas.setStyle("backgroundColor", "#444444");
                      protected function mouseUpHandler(event:MouseEvent):void
                          innerCanvas.setStyle("backgroundColor", "#cccccc");
                      protected function canvas1_clickHandler(event:MouseEvent):void
              <s:Label text="{data.ptName}" x="70" y="5" fontSize="16"/>
              <s:Label text="{data.chiefComplaint}" x="73" y="38" fontSize="14" color="#1343F5"/>
              <s:Image source="{data.faceSource}" x="5" y="5" width="60" height="60" />