0 Replies Latest reply on Jul 12, 2006 2:37 PM by djsodom

    changing icon of selectedItem in a list

    djsodom
      I have a list. When a list item is clicked, a method is called. In this method, I would like to change the icon of the list item that was selected. I can't figure out how.

      Here is what I have:

      <mx:VBox>
      <mx:List id="answers" dataProvider="{aCollection}" change="answerSelected(event) iconField="myIcon" iconFunction="setIcon" />
      </mx:VBox>

      the answerSelectedFunction and related is:

      [Embed(source="green.png")]
      public var newIcon:Class

      private function answerSelected(event:flash.events.Event):void {
      event.currentTarget.selectectedItem.myIcon = "newIcon"
      }

      This is not my whole app, so I know there are things missing (like the setIcon iconFunction ).

      I've tried things like:

      import mx.controls.listClasses; //need this if I try to call ListBases to access my event target property

      private function answerSelected(event:flash.events.Event):void {
      //I know the above is not correct, base on reading page 86 of the flex 2 developers guide
      //it seems like I need something like:
      //ListBase(even.currentTarget).selectedItem.myIcon = "newIcon"
      //but that gives me an error undefined method list base

      rom within my answerSelectedFunction, but can't get it to work.

      Any ideas?

      Steve