我使用的是Flash Builder4,我有一个名为words.xml的外部XML文件,其结构如下:
<wordList>
<wordRecord>
<word>duck</word>
<syllables>1</syllables>
<firstLetter>d</firstLetter>
<!--other fields-->
</wordRecord>
<wordRecord>
<word>machete</word>
<syllables>3</syllables>
<firstLetter>m</firstLetter>
<!--other fields-->
</wordRecord>
<!--more wordRecords-->
</wordList>现在,请注意,这些不是确切的字段名称或内容,因为它们是我的客户的专有名称或内容,这是我的客户的XML文件。但这是基本的结构。我只需要显示列表中每个"wordRecord“中的"word”字段,这将通过拖放和其他功能来启用。
Flash Builder MXML文件的相关部分包括:
<fx:Declarations>
<fx:XML id="wordsXML" source="/xml/words.xml" />
<fx:Declarations>
<s:List id="resultsList">
<s:dataProvider>
<s:XMLListCollection id="xmlWords" source="{wordsXML..word}" />
</s:dataProvider>
</s:List>到现在为止还好。列表在我的Air应用程序中显示得很好,滚动和所有东西,当适当的属性出现时,拖放工作很好。
然而,我需要的是能够根据其他字段过滤列表,并只显示结果中的单词。
现在,让我们假设XML文件包含很多很多"wordRecord“元素,我需要创建一个filterFunction,它最终只提供"firstLetter”为“firstLetter”的“word”,假设是"m“。
我尝试根据我在web上找到的一些示例创建一个filterFunction,但是由于我的XMLListCollection只是字段,所以我无法让filterFunction与其他XML字段一起工作。我尝试将XMLListDeclaration更改为每个"wordRecord“元素作为一个XMLList,但是我不知道如何让s:List从filterFunction的结果中只显示”word“。
有什么想法吗?提前谢谢。
发布于 2012-04-19 14:46:39
<s:List id="resultsList" labelField="word">
<s:dataProvider>
<s:XMLListCollection
id="xmlWords"
source="{wordsXML..wordRecord}"
/>
</s:dataProvider>
</s:List> 这样你就有了过滤器函数的'wordRecord‘对象;
https://stackoverflow.com/questions/10220249
复制相似问题