0

I have list <s:List> in my Flex application that is displaying its list items horizontally, like so:

<s:List id="horzList">
  <s:Layout>
    <s:HorizontalLayout/>
  </s:Layout>

  <s:dataProvider>
    <s:ArrayList>
      <fx:String>Short Item</fx:String>
      <fx:String>Looooonnnnggggeeerrrrr Item</fx:String>
      <fx:String>A really, really, really long item for this list</fx:String>
    </s:ArrayList>
  </s:dataProvider>
</s:List>

Using the change event, how can I fetch the width of one of these items in the horizontal list?

Thank you for your time.

4

1 回答 1

0

哇...这是一个肮脏的烂摊子,但我确实明白了。这是change事件处理程序。顺便说一句,我的实际应用程序使用带有外部数据源的项目渲染器。话虽如此,除非您使用项目渲染器,否则我不知道下面的代码是否有效:

private function changeHandler(e:IndexChangeEvent):void {
  var index:int = horzList.selectedIndex;
  var selected:IVisualElement = horzList.dataGroup.getElementAt(index);
  var width:Number = selected.width;

  //Do something with the width...
}

这个答案对我有很大帮助:https ://stackoverflow.com/a/4035185/663604

希望对某人有所帮助。

于 2012-07-19T20:43:28.237 回答