How can I change the state of the itemRenderer of one member of a flex 4 spark data group?
I have a "step indicator" made out of a DataGroup:
<s:DataGroup id="stepNumbers" itemRenderer="stepNumberRenderer" horizontalCenter="0">
<s:layout>
<s:HorizontalLayout verticalAlign="middle"/>
</s:layout>
</s:DataGroup>
where the dataprovider is 1,2,3,4,5.
The item renderer has 2 states, "norma开发者_开发技巧l" and "active". Within Actionscript, I’d like to be able to set each number to "active" in as needed. So, I need to set "2" to its active state, i.e. stepNumbers[1]. What's the syntax for this?
var item:stepNumberRenderer;
var active:int = 2;
for(var i:uint = 0; i < stepNumbers.numElements; i++)
{
item = stepNumbers.getElementAt(i) as stepNumberRenderer;
If(i == active)
item.currentState = "active";
else
item.currentState = "normal";
}
精彩评论