Jun 27
在前面的Flex中通过设置labelPlacement属性设置RadioButton控件文本标签排列位置的例子中我们利用labelPlacement属性,设置了RadioButton控件文本标签排列位置。其实同样的属性在按钮控件(Button)中也一样可以使用,利用按钮控件(Button)中的labelPlacement属性,我们可以指定一个图标(icon)在按钮中的位置。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.controls.ButtonLabelPlacement;
- [Bindable]
- [Embed('assets/flex_icon.gif')]
- private var Icon:Class;
- ]]>
- </mx:Script>
- <mx:Label text="Button.labelPlacement" />
- <mx:HBox>
- <mx:Button id="bLeft"
- width="120" height="100"
- icon="{Icon}"
- labelPlacement="{bLeft.label}"
- label="{ButtonLabelPlacement.LEFT}" />
- <mx:Button id="bRight"
- width="120" height="100"
- icon="{Icon}"
- labelPlacement="{bRight.label}"
- label="{ButtonLabelPlacement.RIGHT}" />
- <mx:Button id="bTop"
- width="120" height="100"
- icon="{Icon}"
- labelPlacement="{bTop.label}"
- label="{ButtonLabelPlacement.TOP}" />
- <mx:Button id="bBottom"
- width="120" height="100"
- icon="{Icon}"
- labelPlacement="{bBottom.label}"
- label="{ButtonLabelPlacement.BOTTOM}"/>
- </mx:HBox>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer
