0

我在我的应用程序中使用了状态。问题是我已经选择了列表中的第一个项目。所以我给了这样的,

if(itemIndex == 0)
  this.currentState="selected";

this works fine.The problem is when other item is selected the first item does not change its state,it remains in the selected state until its clicked. 我的代码看起来像这样,

<s:BorderContainer id="outerCont" width="275" height="100" borderVisible="false"
                       backgroundColor.normal="#3D3C3C" backgroundAlpha.selected="0.1"
                       backgroundColor.selected="{data.color}">

我的状态是这样的,

<s:states>
    <s:State name="normal" />
    <s:State name="hovered" />
    <s:State id="selState" name="selected" />
</s:states>

提前致谢!!

4

1 回答 1

1

在更改状态的代码中,您永远不会更改回默认状态。所以,当 itemIndex 为 0 时;您设置为选中状态;但没有显示的代码来远离选定的状态。尝试这样的事情:

if(itemIndex == 0)
  this.currentState="selected";
else 
  this.currentState="someOtherState";

要在弹性列表中选择某些内容时更改状态,您可以使用更改事件:

<s:List change="onChange()" />

<fx:Script><[[
  public function onChange():void{
   if(itemIndex == 0)
     this.currentState="selected";
   else 
     this.currentState="someOtherState";
   }
]]></fx:Script>

这有帮助吗?如果不; 您将不得不详细说明。

于 2011-04-26T13:54:29.410 回答