incrementing the number of times a list component is clicked?
I have a list component that lists certain items..
so, if i click on a certain item..i should get the index this way : var clickedIndex:int = listID.selectedIndex; but how can i count the number of times the variabl开发者_如何学运维e clickedIndex has been selected? so, if a user keeps clicking on the index[0], i want to know how many
A couple ideas off the top of my head (I'm assuming your List dataProvider is an ArrayCollection):
Modify the Object you're using in the
ArrayCollection
for your list'sdataProvider
to include aclickCount
property. When an item is selected in the list, increment theclickCount
property. This will keep the correct number of clicks for each item if your ArrayCollection gets sorted or filtered and the indexes change.Create an
Array
variable to store the click counts for each index in your ArrayCollection. Then you would increment the number the the Array's index that matches the ArrayCollection's selectedIndex.
精彩评论