updating HorizontalList icon in flex 3

162 views Asked by At

i have a HorizontalList filled with a dataProvider (ArrayCollection) like :

[Bindable]
[Embed(source="assets/empty.jpg")]
public var empty:Class;


private function init(nbr){
    var myArray : ArrayCollection = new ArrayCollection;

    for( var i=0 ; i<nbr ; i++){
        myArray.addItem({label:"Page" + i , icon:"empty"});
    }
    myHorizontalList.dataProvider = myArray;
}

for some reason i have to do the following, when an item is clicked the icon image of this very item must change to some other image.

can anybody help me please. i'm new to flex thank you

1

There are 1 answers

1
Jack Zach Tibbles On

You should use the change event on your list. That should call a method to change the selected image. Something like this:

<mx:List id="imageList" dataProvider="{dataList}" change="{onChange(event)}" />

public function onChange(event:Event):void
{
    image.source = imageList.selectedItem.url; 
}

If you need any further explanation let me know.