以编程方式启用/禁用 Flex 4 中的菜单栏按钮
我的 Flex4 (AIR) 项目中有以下 XML,它定义了菜单界面的开始:
<mx:MenuBar x="0" y="0" width="100%" id="myMenuBar" labelField="@label" itemClick="menuChange(event)">
<mx:dataProvider>
<s:XMLListCollection>
<fx:XMLList xmlns="">
<menu label="File">
<item label="New"/>
<item label="Load"/>
<item label="Save" enabled="false"/>
</menu>
<menu label="Help">
<item label="About"/>
</menu>
</fx:XMLList>
</s:XMLListCollection>
</mx:dataProvider>
</mx:MenuBar>
我正在尝试找到一种语法,可以让我在通过单击“加载”加载文件后将保存按钮设置为启用=true ”,但是我无法弄清楚语法,请有人提出建议。
目前检测按钮点击的方式是通过 Switch/Case 测试 MenuEvent event.item.@label 的字符串结果。也许这不是最好的方法?
I have the following XML in my Flex4 (AIR) project that defines the start of my menu interface:
<mx:MenuBar x="0" y="0" width="100%" id="myMenuBar" labelField="@label" itemClick="menuChange(event)">
<mx:dataProvider>
<s:XMLListCollection>
<fx:XMLList xmlns="">
<menu label="File">
<item label="New"/>
<item label="Load"/>
<item label="Save" enabled="false"/>
</menu>
<menu label="Help">
<item label="About"/>
</menu>
</fx:XMLList>
</s:XMLListCollection>
</mx:dataProvider>
</mx:MenuBar>
I am trying to find the syntax that will let me set the save button to enabled=true after a file has been loaded by clicking "Load", however I can't figure out the syntax, can someone make a suggestion please.
Currently the way that button clicks are detected is by a Switch/Case testing the String result of the MenuEvent event.item.@label. Maybe this isn't the best way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
再次回答我自己的问题....。我正在做的事情是怎么回事,似乎没有人愿意回答???
无论如何,这里是:
事实证明,由于菜单栏是在 XML 中定义的,并且它是完全任意的,因此它完全取决于您决定如何定义菜单,在我的例子中,根据上面的菜单 XML,更改“保存按钮的“eanabled”状态如下。
其中 enubarXML 是一个 XMLListCollection,其中包含我单独重新定义的 XMLList。
然后在应用程序创建完成时调用此函数:
当然还有菜单栏的 XML 定义(根据需要自定义):
希望有人发现我的劳动成果有用。
Answering my own question .... yet again. What is it with the stuff I'm doing nobody seems to want to answer???
Anyway, here it is:
It turns out that since the menubar is defined in XML and it's completely arbitrary, it depends totally on how you decide to define your menu, in my case, according to the menu XML above, the syntax to changethe "eanabled" state of the Save button would be as follows.
where enubarXML is an XMLListCollection holding the XMLList which I redefined seperately.
Then call this function on the apps creation complete:
and of course the XML definition of the menubar (customise this as required):
Hope someone finds the fruits of my labour useful.