Apache flex Flex4按钮杆设置图标不';行不通

Apache flex Flex4按钮杆设置图标不';行不通,apache-flex,Apache Flex,但这不起作用,图标不显示,为什么会发生这种情况???您必须在Buttonbar mxml标记中提到iconfield属性作为图标,如下所示:- <s:ButtonBar id="buttonBar" width="100%" height="100%" fontSize="15" dataProvider="{buttonBarData}" change="buttonBar_changeHandler(event)"/> <fx:Decl

但这不起作用,图标不显示,为什么会发生这种情况???

您必须在Buttonbar mxml标记中提到iconfield属性作为图标,如下所示:-

<s:ButtonBar id="buttonBar"  width="100%" height="100%" fontSize="15" 
                 dataProvider="{buttonBarData}" change="buttonBar_changeHandler(event)"/>
<fx:Declarations>
    <s:ArrayList id="buttonBarData">
        <fx:Object label="test" icon="{newIcon}" cmd="openfile"/>
        <fx:Object label="test" icon="{openIcon}" cmd="openfile" />
        <fx:Object label="test" icon="{saveIcon}" cmd="savefile"/>
        <fx:Object label="test" icon="{checkIcon}" cmd="check"/>
        <fx:Object label="test" icon="{undoIcon}" cmd="undo"/>
        <fx:Object label="test" icon="{redoIcon}" cmd="redo"/>
    </s:ArrayList>
</fx:Declarations>


只有它才能识别从哪个字段获取图标。

谢谢您回答这个问题!!但是flex4 buttonbar没有iconField属性。在我设置了iconField之后,它就不起作用了。我使用了你的代码进行测试,它在iconField中工作得很好。Spark ButtonBar肯定具有iconField属性。您是在数据提供程序中使用嵌入的icon类还是仅使用icon path变量?Wit嵌入式图标类工作正常。是的,我使用嵌入式图标类。现在,当我使用MXButtonbar时,代码工作得非常完美。但是当我像s:ButtonBar那样使用Spark ButtonBar时,代码就不起作用了。我在编辑器中使用Flex Builder,但它不提示iconField属性。它对我来说工作正常。根据Adobe文档,iconField属性存在。查看以下链接。在该链接中,您可以在公共继承属性中看到iconfield属性
<s:ButtonBar id="buttonBar"  width="100%" height="100%" fontSize="15" 
             dataProvider="{buttonBarData}" change="buttonBar_changeHandler(event)" iconField="icon"/>