• flex中为控件添加监听器并计算


    1、添加监听器:

    public function moduleCreationComplete():void
                {
                    this.D601_29a.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    this.D601_30a.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    this.D601_31a.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    this.D601_29b.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    this.D601_30b.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    this.D601_31b.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_28);
                    
                    this.D601_36.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_35);
                    this.D601_37.addEventListener(FlexEvent.SELECTION_CHANGE,setD601_35);
                    this.D601_65.addEventListener(FlexEvent.CHANGING,setD601_07);
                    this.D601_65.addEventListener(FlexEvent.ENTER,setD601_07);
                }

    2、写计算函数:

    public function setD601_28(event:Event):void
                {//计算小时分钟
                    var firsta:Number = Number(this.D601_29a.text);
                    var firstb:Number = Number(this.D601_29b.text);
                    var seconda:Number = Number(this.D601_30a.text);
                    var secondb:Number = Number(this.D601_30b.text);
                    var thirda:Number = Number(this.D601_31a.text);
                    var thirdb:Number = Number(this.D601_31b.text);
                    
                    this.D601_28a.text = (Math.floor(((firsta + seconda + thirda)*60 +firstb + secondb + thirdb) / 60)).toString();
                    this.D601_28b.text = (((firsta + seconda + thirda)*60 +firstb + secondb + thirdb) % 60).toString();
                }
                public function setD601_35(event:Event):void
                {
                    var chanshi:Number = Number(this.D601_36.text);
                    var chanhou:Number = Number(this.D601_37.text);
                    
                    this.D601_35.text = (chanshi + chanhou).toString();
                }
                public function setD601_07(event:Event):void
                {//根据身份证号计算年龄
    var cardId:String = this.D601_65.text; if(cardId.length >= 16) { var year:Number = Number(this.D601_65.text.substr(6,4)); var month:Number = Number(this.D601_65.text.substr(10,2)); var day:Number = Number(this.D601_65.text.substr(12,2)); var date:Date = new Date(); var nowMonth = date.month + 1; var age = date.fullYear - year; if(month > nowMonth || month == nowMonth && day >= date.date) { age++; } this.D601_07.text=age; } }


    我很小我很弱,我在慢慢成长!
  • 相关阅读:
    开发和使用自定义服务器控件
    用户认证管理设计方案(转)
    用 @@ERROR 检测几条语句的成功
    在 ASP.NET 中支持数据库缓存相关性
    给新人程序员的八点建议(转)
    DataTable添加列
    各城市工资多少才等于北京5000元工资的生活?
    连续读取区块应用程序设置值
    VS2005 SP1发布,解决只能创建WebSite,无法创建Web Application项目的问题 (转)
    帮你免于失业的十大软件技术
  • 原文地址:https://www.cnblogs.com/lvzhanhui/p/xiaoqiaolv_flex_listenner.html
Copyright © 2020-2023  润新知