当前位置: 动力学知识库 > 问答 > 编程问答 >

actionscript 3 - FB 4.6 - list component -- prepend labels with an item count?

问题描述:

I have a list component that uses a sqlite database as the dataProvider and am able to use labelField to show the data labels just fine... I want to, however, affix an incremental count before the label field so its listed as

1.) item number 1

2.) item number 2 ... etc...

I discovered labelFunct and wrote the following to test it out:

private function lblFunct(value:Object):String

{

return value.id + ") " + value.question;

}

and that shows the automatically assigned database ID before the label text just fine.... my goal is to try to get a COUNT of each item though... I can get the LENGTH of the data provider with

myListComponentID.dataProvider.length

but cant find any info on how to achieve an incremental count. is it possible to construct some sort of for each loop in the labelFunct? can anyone shed any light on this? Thanks in advance.

网友答案:

You're on the right track with the labelFunction. You can use getItemIndex method on your dataProvider to determine the itemIndex of the displayed item:

private function lblFunct(value:Object):String
{
   return myListComponentID.dataProvider.getItemIndex(value) + ") " + value.question;
}
网友答案:

with help from the person who responded, I found my way to the solution... the fabel funct ended up looking like this:

private function lblFunct(value:Object):String
{
    return (myListComponentID.dataProvider.getItemIndex(value)+1) + ") " + value.question;
}

I added the +1 to compensate for the fact that its zero based. thanks to the responder though, you helped me find my way to the answer. Much appreciated!

分享给朋友:
您可能感兴趣的文章:
随机阅读: