Flex中通过将labelPlacement属性值设置为ButtonLabelPlacement类中定义的一个常量实现设置LinkButton控件图标位置的例子

By Minidxer | September 6, 2008

在前面的Flex中通过icon样式给LinkButton控件设置一个图标的例子中我们了解了如何给LinkButton添加一个图标。接下来的例子演示了Flex中通过将labelPlacement属性值设置为ButtonLabelPlacement类中定义的一个常量,实现设置LinkButton控件图标位置。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="LinkButton_labelPlacement_test"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             import mx.controls.ButtonLabelPlacement;
  11.         ]]>
  12.     </mx:Script>
  13.  
  14.     <mx:Array id="arr">
  15.         <mx:String>{ButtonLabelPlacement.LEFT}</mx:String>
  16.         <mx:String>{ButtonLabelPlacement.RIGHT}</mx:String>
  17.         <mx:String>{ButtonLabelPlacement.TOP}</mx:String>
  18.         <mx:String>{ButtonLabelPlacement.BOTTOM}</mx:String>
  19.     </mx:Array>
  20.  
  21.     <mx:ApplicationControlBar dock="true">
  22.         <mx:Form styleName="plain">
  23.             <mx:FormItem label="labelPlacement:">
  24.                 <mx:ComboBox id="comboBox"
  25.                         dataProvider="{arr}"
  26.                         selectedIndex="1" />
  27.             </mx:FormItem>
  28.         </mx:Form>
  29.     </mx:ApplicationControlBar>
  30.  
  31.     <mx:LinkButton id="linkButton"
  32.             label="LinkButton"
  33.             labelPlacement="{comboBox.selectedItem}"
  34.             icon="@Embed('assets/LinkButton.png')" />
  35.  
  36. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Flex | No Comments » | 80 views Tags: , , ,

Search Posts