当前位置:主页>Flex>文章内容
  • Flex例4【列表形式控件的运用】
  • 来源: 作者: 2007-09-29 【

Use List-based Form Controls不知道怎么翻,大致是这个意思了。这个例子主要讲了ComboBox的使用。
<mx:dataProvider>
    <mx:Array>
......之间可以使用两种tag......
    </mx:Array>
</mx:dataProvider>

1。一种是<mx:String>...</mx:String>,可以用一个label绑定它中间的值.
2。另一种是<mx:Object label="..." data="..."/>,label属性是显示的值;data属性是它的value值,可以用label绑定。The value property contains the value of the selected item. When a data field is
specified, the value property refers to the data field, not the label field. In
the example, the cbxRating.value property could contain the values 5, 3, or 1,
depending on the user's selection。

label标签中用{}绑定控件的值,如:<mx:Label x="20" y="120" text="{cbxRating.value}"/>

以下是MXML代码:

程序代码 程序代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 width="400" height="200">
    <mx:Panel x="10" y="10" width="380" height="180" layout="absolute"
 title="Rate Customer Service">
        <mx:ComboBox x="20" y="20" id="cbxRating">
        <mx:dataProvider>
            <mx:Array>
            <mx:String>Apple</mx:String>
            <mx:String>Orange</mx:String>
            <mx:String>Peach</mx:String>
            <mx:Object label="Satisfied" data="5"/>
            <mx:Object label="Neutral" data="3"/>
            <mx:Object label="Dissatisfied" data="1"/>
            </mx:Array>
        </mx:dataProvider>
        </mx:ComboBox>
        <mx:Button x="140" y="20" label="Send"/>
        <mx:Label x="140" y="69" text="{cbxRating.value}" color="#ff0000"/>
    </mx:Panel>    
</mx:Application>




上一篇:Flex例3【创建适应浏览器的布局】   下一篇:Flex例5【使用Event Listener】
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)