flex radiobutton checkbutton combox color flex 教程 flex培训 flex源码 flex实例

 flex 单选框,复选框 下拉框,及颜色选择框。

现在的版本已经升级到flex4 了,我在网上找的部分代码还是flex 3 的,因为代码升级的原因,大部分的flex3代码是可以运行的,还有一部分内容不能运行了,还要做一些改动或升级。最主要的区别是flex 3 默认主题是halo,而flex4 已经升级为spark,相应的标记也由mx升级为s.详细的区别还要再查找资料。

本系列的源码主要来自于网上,同时,还有来自于《自学flex》一书中。

<?xml version="1.0" encoding="utf-8"?>
<!--转:http://blog.sina.com.cn/s/blog_6dd3fe2e0100pa6v.html-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
  
 </fx:Declarations>
 <!--flex3 中的script 要用mx  flex4中要用到fx-->
 <fx:Script>
  
  
  <![CDATA[
   protected function button1_clickHandler(event:MouseEvent):void
   {
    // TODO Auto-generated method stub
                var s :String;
    s="";
    if(cbVideoGames.selected)
    {
     s = s + cbVideoGames.label;
    }
    if(cbFishing.selected)
    {
     s = s + cbFishing.label;
    }
    mx.controls.Alert.show(s);
   }
   
   public function showMsg(msg:String):void
      {
      mx.controls.Alert.show(msg);
      }
  ]]>
  
 </fx:Script>
 
 <mx:Panel width="400" height="150" title="Profile">
  
  <!-- *** CHECKBOX EXAMPLE *** -->
  <mx:HBox>
   <mx:Label text="Your hobbies:"/>
   <mx:CheckBox id="cbVideoGames" label="Video Games"
       click="showMsg('Video Games is ' + cbVideoGames.selected)"/>
   <mx:CheckBox id="cbFishing" label="Fishing"
       click="showMsg('Fishing is ' + cbFishing.selected)"/>
  </mx:HBox>
  
  <!-- *** RADIO BUTTON EXAMPLE *** -->
  <mx:HBox>
   <mx:Label text="Do you like spam:"/>
   <!-- This is going to cause two popups occur. -->
   <!-- The click event on the radiobutton will fire -->
   <!-- And then the itemClick on the radio button group will fire -->
   <!-- The RadioButtonGroup is optional. -->
   <!-- Use it when you need to call a single function regardless -->
   <!-- of radio button -->
   <mx:RadioButtonGroup id="Spam"
         itemClick="showMsg('User picked ' + event.currentTarget.selectedValue)"/>
   <mx:RadioButton id="rbYes" value="Yes" groupName="Spam"
       click="showMsg('Yes')" label="Yes"/>
   <mx:RadioButton id="rbNo" value="No" groupName="Spam"
       click="showMsg('No')" label="No"/>
  </mx:HBox>
  
  <!-- *** COMBOBOX AND COLORPICKER EXAMPLE *** -->
  <mx:HBox>
   <mx:Label text="Favorite car maker:"/>
   <mx:ComboBox id="combo"
       change="showMsg('Favorite car is ' + event.currentTarget.selectedItem)">
    <!--flex3 中的array 要用mx  flex4中要用到fx-->
    <fx:Array>
     <fx:String>Ferrari</fx:String>
     <fx:String>Porsche</fx:String>       
     <fx:String>Hyundai</fx:String>        
    </fx:Array>
   </mx:ComboBox>
   <mx:Label text="With the color of:"/>
   <mx:ColorPicker id="clr"
       change="showMsg('Color ' + event.currentTarget.selectedColor)"/>
  </mx:HBox>
  <s:Button label="按钮" click="button1_clickHandler(event)"/>
  
 </mx:Panel>
 

</s:Application>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值