- 浏览: 20133 次
- 性别:
- 来自: 北京
文章分类
最新评论
package com { import flash.events.Event; import flash.events.FocusEvent; import flash.text.TextLineMetrics; import mx.containers.HBox; import mx.controls.NumericStepper; import mx.controls.Text; import mx.controls.TextInput; import mx.core.UITextField; import mx.core.mx_internal; import mx.events.FlexEvent; import mx.managers.IFocusManager; use namespace mx_internal; /** * Dispatched when the time changes, which could be either the hour, minute. */ [Event(name="change",type="flash.events.Event")] /** * Dispatched when the hour changes. */ [Event(name="hoursChange",type="flash.events.Event")] /** * Dispatched when the minutes change. */ [Event(name="minutesChange",type="flash.events.Event")] /** * Dispatched when the seconds change. */ [Event(name="secondsChange",type="flash.events.Event")] public class TimeInputEx extends NumericStepper { /** * 时间转换字符串 */ public static function formatNumberWithChar(value:Number,length:int=2,pref:String="0"):String { var str:String = new String(value); var len:int = str.length; if(len > length) { return str.substr(0,length); } else { var n:int = length - len; for( var i:int = 0 ; i < n ; i++ ) { str = pref + str; } return str; } } /** * Construction */ public function TimeInputEx() { super(); this.maxChars = 2; this.minimum = 0; this.maximum = 23; this.stepSize = 1; this.addEventListener(FlexEvent.VALUE_COMMIT,valueCommandHandler); } //-------------------------------------------------------------------------- // // Variables // //-------------------------------------------------------------------------- /** * @private */ protected var inputBox:HBox; /** * @private */ protected var sText:Text; protected var sText2:Text; /** * @private */ protected var hoursInputField:TextInput; /** * @private */ protected var minutesInputField:TextInput; /** * @private */ protected var secondsInputField:TextInput; /** * @private */ protected var _hours:Number = 0; /** * @private */ protected var _minutes:Number = 0; /** * @private */ protected var _seconds:Number = 0; /** * @private */ protected var _time:Date; /** * @private */ protected var _text:String; /** * @private */ private var _enabled:Boolean=true; /** * @override creationChildren */ override protected function createChildren():void { super.createChildren(); if(!inputBox) { inputBox = new HBox(); inputBox.setStyle("paddingLeft",0); inputBox.setStyle("paddingRight",0); inputBox.setStyle("paddingTop",0); inputBox.setStyle("paddingBottom",0); inputBox.setStyle("horizontalGap",0); inputBox.setStyle("borderStyle","solid"); inputBox.setStyle("verticalAlign","middle"); addChild(inputBox); } var v:String = "00"; var lineMetrics:TextLineMetrics = this.measureText(v); var textWidth:Number = lineMetrics.width + UITextField.TEXT_WIDTH_PADDING; var textHeight:Number = lineMetrics.height + UITextField.TEXT_HEIGHT_PADDING; if (!hoursInputField) { hoursInputField = new TextInput(); hoursInputField.focusEnabled = false; hoursInputField.styleName = this; // restrict to numbers - dashes - commas - decimals hoursInputField.restrict = "0-9"; hoursInputField.maxChars = 2; hoursInputField.text = formatNumberWithChar(_hours,2,"0"); hoursInputField.width = textWidth; hoursInputField.height = textHeight; //hoursInputField.parentDrawsFocus = true; hoursInputField.setStyle("textAlign","right"); hoursInputField.setStyle("borderStyle","none"); hoursInputField.setStyle("paddingLeft",0); hoursInputField.setStyle("paddingRight",0); hoursInputField.setStyle("paddingTop",0); hoursInputField.setStyle("paddingBottom",0); hoursInputField.setStyle("horizontalGap",0); hoursInputField.addEventListener(FocusEvent.FOCUS_IN,inputField_focusInHandler); hoursInputField.addEventListener(FocusEvent.FOCUS_OUT, inputField_focusOutHandler); inputBox.addChild(hoursInputField); } inputField=hoursInputField; if(!sText){ sText=new Text(); sText.text=":"; sText.setStyle("textAlign","center"); sText.setStyle("paddingLeft",0); sText.setStyle("paddingRight",0); sText.setStyle("paddingTop",0); sText.setStyle("paddingBottom",0); sText.setStyle("horizontalGap",0); inputBox.addChild(sText); } if (!minutesInputField) { minutesInputField = new TextInput(); minutesInputField.focusEnabled = false; minutesInputField.styleName = this; // minutesInputField.width=textWidth; // restrict to numbers - dashes - commas - decimals minutesInputField.restrict = "0-9"; minutesInputField.maxChars = 2; minutesInputField.text = formatNumberWithChar(_minutes,2,"0"); minutesInputField.width = textWidth; minutesInputField.height = textHeight; //minutesInputField.parentDrawsFocus = true; minutesInputField.setStyle("textAlign","left"); minutesInputField.setStyle("borderStyle","none"); minutesInputField.setStyle("paddingLeft",0); minutesInputField.setStyle("paddingRight",0); minutesInputField.setStyle("paddingTop",0); minutesInputField.setStyle("paddingBottom",0); minutesInputField.setStyle("horizontalGap",0); minutesInputField.addEventListener(FocusEvent.FOCUS_IN,inputField_focusInHandler); minutesInputField.addEventListener(FocusEvent.FOCUS_OUT, inputField_focusOutHandler); inputBox.addChild(minutesInputField); } if(!sText2){ sText2=new Text(); sText2.text=":"; sText2.setStyle("textAlign","center"); sText2.setStyle("paddingLeft",0); sText2.setStyle("paddingRight",0); sText2.setStyle("paddingTop",0); sText2.setStyle("paddingBottom",0); sText2.setStyle("horizontalGap",0); inputBox.addChild(sText2); } if (!secondsInputField) { secondsInputField = new TextInput(); secondsInputField.focusEnabled = false; secondsInputField.styleName = this; // secondsInputField.width=textWidth; // restrict to numbers - dashes - commas - decimals secondsInputField.restrict = "0-9"; secondsInputField.maxChars = 2; secondsInputField.text = formatNumberWithChar(_seconds,2,"0"); secondsInputField.width = textWidth; secondsInputField.height = textHeight; //secondsInputField.parentDrawsFocus = true; secondsInputField.setStyle("textAlign","left"); secondsInputField.setStyle("borderStyle","none"); secondsInputField.setStyle("paddingLeft",0); secondsInputField.setStyle("paddingRight",0); secondsInputField.setStyle("paddingTop",0); secondsInputField.setStyle("paddingBottom",0); secondsInputField.setStyle("horizontalGap",0); secondsInputField.addEventListener(FocusEvent.FOCUS_IN,inputField_focusInHandler); secondsInputField.addEventListener(FocusEvent.FOCUS_OUT, inputField_focusOutHandler); inputBox.addChild(secondsInputField); } } /** * @private * Return the preferred sizes of the stepper. */ override protected function measure():void { super.measure(); var inputBoxHeight:Number = inputBox.getExplicitOrMeasuredHeight(); var buttonHeight:Number = prevButton.getExplicitOrMeasuredHeight() + nextButton.getExplicitOrMeasuredHeight(); var h:Number = Math.max(inputBoxHeight, buttonHeight); h = Math.max(DEFAULT_MEASURED_MIN_HEIGHT, h); var inputBoxWidth:Number = inputBox.getExplicitOrMeasuredWidth(); var buttonWidth:Number = Math.max(prevButton.getExplicitOrMeasuredWidth(), nextButton.getExplicitOrMeasuredWidth()); var w:Number = inputBoxWidth + buttonWidth; w = Math.max(DEFAULT_MEASURED_MIN_WIDTH, w); measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH; measuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT; measuredWidth = w; measuredHeight = h; } /** * @private * Place the buttons to the right of the text field. */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); var w:Number = nextButton.getExplicitOrMeasuredWidth(); var h:Number = Math.round(unscaledHeight / 2); var h2:Number = unscaledHeight - h; nextButton.x = unscaledWidth - w; nextButton.y = 0; nextButton.setActualSize(w, h2); prevButton.x = unscaledWidth - w; prevButton.y = unscaledHeight - h; prevButton.setActualSize(w, h); var inputBoxHeight:Number = inputBox.getExplicitOrMeasuredHeight(); var inputBoxWidth:Number = inputBox.getExplicitOrMeasuredWidth(); inputBox.setActualSize(unscaledWidth - w, unscaledHeight); trace(unscaledWidth - w + " " + unscaledHeight); // inputBox.setActualSize(inputBoxWidth,inputBoxHeight); } /** * @private */ private function inputField_focusInHandler(event:FocusEvent):void { if (this.listData) { this.Caption = this.listData.label; } inputField=event.currentTarget as TextInput; if(event.currentTarget as TextInput == hoursInputField){ this.value=parseInt(inputField.text); this.minimum=0; this.maximum=23; }else{ this.value=parseInt(inputField.text); this.minimum=0; this.maximum=59; } focusInHandler(event); // Send out a new FocusEvent because the TextInput eats the event // Make sure that it does not bubble. dispatchEvent(new FocusEvent(event.type, false, false, event.relatedObject, event.shiftKey, event.keyCode)); } /** * @private */ private function inputField_focusOutHandler(event:FocusEvent):void { if (this.listData) { this.listData.label = this.Caption; } focusOutHandler(event); // Send out a new FocusEvent because the TextInput eats the event // Make sure that it does not bubble dispatchEvent(new FocusEvent(event.type, false, false, event.relatedObject, event.shiftKey,event.keyCode)); } /** * @private * * do for format number to string */ private function valueCommandHandler(event:FlexEvent):void{ //var v=this.value; inputField.text=formatNumberWithChar(value,2,"0"); if(inputField==hoursInputField){ this.hours=value; } else if(inputField==minutesInputField){ this.minutes=value; } else if(inputField==secondsInputField){ this.seconds=value; } this.Caption=formatNumberWithChar(this.hours,2,"0") +":"+formatNumberWithChar(this.minutes,2,"0") +":"+formatNumberWithChar(this.seconds,2,"0"); } /** * @private * Remove the focus from the text field. */ override protected function focusInHandler(event:FocusEvent):void { super.focusInHandler(event); var fm:IFocusManager = focusManager; if (fm) fm.defaultButtonEnabled = false; } [Bindable] /** * The hours (an integer from 0 to 23) of the day. * * @default 0 */ public function get hours():Number { return _hours; } [Inspectable(defaultValue=0,category="Time",name="Hours")] public function set hours(val:Number):void { if (val >= 0 || val <= 24) { this._hours = val; if(inputField){ if(inputField==hoursInputField && val!=value) value=val; else{ hoursInputField.text=formatNumberWithChar(val,2,"0"); } } } dispatchEvent(new Event("hoursChange")); dispatchEvent(new Event("change")); } [Bindable] /** * The minutes (an integer from 0 to 59) passed in the hours. * * @default 30 */ public function get minutes():Number { return _minutes; } [Inspectable(defaultValue=30,category="Time",name="Minutes")] public function set minutes(val:Number):void { if (val >= 0 || val <= 59) { this._minutes = val; if(inputField){ if(inputField==minutesInputField && val!=value) value=val; else{ minutesInputField.text=formatNumberWithChar(val,2,"0"); } } } dispatchEvent(new Event("minutesChange")); dispatchEvent(new Event("change")); } [Bindable] /** * The seconds (an integer from 0 to 59) passed in the hours. * * @default 30 */ public function get seconds():Number { return _seconds; } [Inspectable(defaultValue=30,category="Time",name="Seconds")] public function set seconds(val:Number):void { if (val >= 0 || val <= 59) { this._seconds = val; if(inputField){ if(inputField==secondsInputField && val!=value) value=val; else{ secondsInputField.text=formatNumberWithChar(val,2,"0"); } } } dispatchEvent(new Event("secondsChange")); dispatchEvent(new Event("change")); } public function get Time():Date{ var d:Date=new Date(); d.hours=_hours; d.minutes=_minutes; d.seconds=_seconds; return d; } public function set Time(time:Date):void{ this._time=time; this.hours=time.hours; this.minutes=time.minutes; this.seconds=time.seconds; } [Bindable] public function get Caption():String{ return _text; } [Inspectable(defaultValue="00:00:00",category="Caption",name="Caption")] public function set Caption(timestr:String):void{ this._text=timestr; this.hours=Number(timestr.substring(0,2)); this.minutes=Number(timestr.substring(3,5)); this.seconds=Number(timestr.substring(6,8)); } /** * @private */ override public function set enabled(value:Boolean):void { _enabled = value; if(hoursInputField){ hoursInputField.enabled=value; minutesInputField.enabled=value; secondsInputField.enabled=value; sText.enabled=value; sText2.enabled=value; nextButton.enabled=value; prevButton.enabled=value; } } /** * @private */ override public function get enabled():Boolean { return _enabled; } } }
<?xml version="1.0" encoding="utf-8"?> <mx:Application creationComplete="init();" xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="12" layout="horizontal" xmlns:ns1="*" xmlns:com="com.*"> <mx:Script> <![CDATA[ private function init():void{ ac.addItem({starttime:"00:00:00", endtime:"01:00:00", program:""}); ac.addItem({starttime:"01:00:00", endtime:"02:00:00", program:""}); } ]]> </mx:Script> <mx:DateFormatter id="timeFormatter" formatString="J:NN:SS A" /> <mx:ArrayCollection id="ac"/> <mx:Panel layout="absolute" paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5" title="TimeInput" width="100%" height="224"> <com:TimeInputEx id="timerinput" hours="23" minutes="45" width="250" seconds="30" Caption="03:45:30" top="10"/> <mx:DataGrid textAlign="center" id="dg" dataProvider="{ac}" sortableColumns="false" fontSize="14" editable="true" alternatingItemColors="[#ffffff, #d1d1d1]" headerColors="[#ffffff, #d1d1d1]" alpha="0.6" left="10" right="10" top="51" bottom="29"> <mx:columns> <mx:DataGridColumn headerText="start time" dataField="starttime" textAlign="center" editable="true" minWidth="125" itemEditor="com.TimeInputEx" editorDataField="Caption"/> <mx:DataGridColumn headerText="end time" dataField="endtime" textAlign="center" editable="true" minWidth="125" itemEditor="com.TimeInputEx" editorDataField="Caption"/> </mx:columns> </mx:DataGrid> </mx:Panel> <mx:Panel layout="vertical" paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5" title="time now"> <mx:Text text="hours:{timerinput.hours}"/> <mx:Text text="minutes:{timerinput.minutes}"/> <mx:Text text="seconds:{timerinput.seconds}"/> <mx:Text text="caption:{timerinput.Caption}"/> <mx:Button label="setTime to 8:10:03" click="timerinput.Caption='08:10:03'" /> <mx:Button label="switchEnable" click="if(timerinput.enabled) timerinput.enabled=false; else timerinput.enabled=true;"/> </mx:Panel> </mx:Application>
什么都不说了,自己看代码吧,TimerInputEx中只是在原有基础之上增加了label和input
发表评论
-
ColorLabel
2014-06-19 09:46 437package com.components { imp ... -
Flex菜单弹跳效果
2014-03-14 15:06 1112一个很简单的单击效果(弹跳,选中时加下划线),可适用于菜单单击 ... -
Flex4动态加载组件存在的问题
2014-03-13 10:14 1182为了提高Spark组件性能,Adobe做了很多,但凡事均有利弊 ... -
Flex DragManager
2013-12-30 16:34 434当用户使用鼠标选择某个项目时,所选组件称之为启动器,移动过程中 ... -
AdvancedDatagrid分组、显示概要信息及问题
2013-12-27 17:28 440<?xml version="1.0" ... -
Flex日志使用及配置
2013-02-26 12:43 721Flex集成一个Log框架,可以完成很多用trac ... -
Flex 读写本地文件(Flash Player 10)
2013-02-26 11:43 1503FileReference 类提供了在用户计算机和 ... -
Flex FileReference URLRequest 请求缓存问题
2013-02-19 10:20 1199UrlRequest请求时会缓存会话 ... -
Flex 资源链接
2013-01-31 10:47 687RIA爱好者 http://www.riafan.com Co ... -
Flex 4 组件继承关系
2013-01-05 09:55 796. -
自定义的组件中加入多个MXML标记的子UI元素 (转)
2012-11-29 15:24 903首先我们来看一下它定 ... -
Flex 3 与 Flex 4 之间的区别 (转载)
2012-11-23 14:00 589http://www.adobe.com/cn/devn ... -
Flex 4 随记
2012-11-23 13:41 6431. Flex多状态事件 private functio ... -
Flash Builder 4.6 破解
2012-11-20 10:46 2具体步骤如下:1.到Adobe官网下载FlashBuil ... -
Flex HtmlButton 控件
2012-11-19 10:24 769package com { import flash ... -
探究Flex声明周期 (转载 IBM)
2012-11-16 17:14 643http://www.ibm.com/developerwor ... -
Flex 组件 生命周期
2012-11-16 16:12 9091、生命周期简述 (1) Constructio ... -
Flex 杂篇
2012-11-08 13:44 7071.复制内容到系统剪贴板System.setClipbo ... -
Failed to connect; session timed out.(无法连接,会议超时)
2012-11-06 16:23 1433Failed to connect; session time ...
相关推荐
定时器输入监视输入或textarea元素的值是否已更改,例如input事件。用法 var keyword = document . getElementById ( 'keyword' ) ;var kwInput = new TimerInput ( keyword ) ;kwInput . on ( function ( e ) { ...
当用户点击StartButton时,会触发一个事件处理程序,该处理程序将用户在timerInput中输入的时间转换为秒,并将其存储在变量`alarmTime`中。然后,启动`timerClock`,并设置其Elapsed事件处理程序,以便在时间到达时...
项目中常见的问题,记录一下解决方案
avnet(安富利)网站详情页数据样例
该数据集涵盖了2005至2012年间全国各地区二级专业承包建筑业企业的利润总额。这些数据不仅包括了原始数据,还提供了线性插值和ARIMA填补的版本,以便于研究者能够根据不同的需求选择合适的数据形式进行分析。数据集中包含了行政区划代码、地区名称、是否属于长江经济带、经纬度信息、年份以及利润总额等关键指标。这些指标为评估企业的经营效益和盈利水平提供了重要依据,同时也反映了建筑业在不同地区的发展态势。数据来源为国家统计局,确保了数据的权威性和准确性。通过这些数据,研究者可以深入分析建筑业的经济贡献及其在宏观经济中的作用,为政策制定和行业规划提供数据支持。
本文档主要讲述的是CentOS6.4 X64安装Oracle11g;在CentOS安装oracle11g比安装oracle10g简单很多,oracle可以不设置比如OS内核参数、防火墙、环境变量等,所以实施时推荐安装oracle11g。感兴趣的朋友可以过来看看
发动机零部件质量信息反馈及处理表.docx
全国省市县土地利用类型面板数据2009-2021年是一项详尽的数据集,它基于土地利用方式和地域差异,对土地资源单元进行细致划分,反映了土地的用途、性质和分布规律。该数据集涵盖了全国各省、地级市、县的土地利用类型,包括耕地、园地、林地、交通运输用地、水域及沙地等多种土地类型。时间范围上,省级和地级市的土地利用类型面板数据覆盖2009至2021年;县级土地利用类型面板数据则从2019年开始至2021年。数据指标丰富,包括行政单位、年份以及各类土地利用的具体分类,如水田、水浇地、旱地、果园、茶园等,以及城镇村及工矿用地、交通运输用地、水域及水利设施用地等。这些数据为政府决策、规划编制以及土地资源管理提供了坚实的数据基础,有助于全面了解土地资源的利用状况,并为未来的规划和管理提供支持。
项目中常见的问题,记录一下解决方案
好课分享——前端跳槽突围课:React18底层源码深入剖析(完结21章)
1111java后端1111Controller
嵌入式系统开发-STM32单片机-电子春联-代码设计
潜在失效模式及后果分析(FMEA)应用流程.docx
内容概要:本文详细介绍了如何使用Python和Matplotlib库创建一个动态的3D圣诞树动画。通过代码示例,展示了几何形状的创建方法,如圣诞树的形状、装饰品和星星的位置计算,以及如何通过动画更新函数实现闪烁效果。 适合人群:具有一定Python编程基础的开发者,尤其是对Matplotlib库和数据可视化感兴趣的读者。 使用场景及目标:① 学习Matplotlib库的基本用法,包括3D绘图和动画制作;② 掌握几何形状的数学建模方法,如圆锥和球体;③ 实践动画效果的实现技巧,提升编程技能。 阅读建议:本教程以具体代码示例为主,理论与实践相结合。建议读者在阅读过程中亲自编写和运行代码,逐步理解每一步骤的实现细节。
开发一个带有 PCIe Endpoint 设备的驱动程序并实现热插拔功能
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
消防气压给水设备和稳压泵安装 分项工程质量验收记录表.docx
Cytoscape-3-10-0-windows-64bit.exe
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。