Flex表单中回车下移焦点的方法
对于习惯了使用桌面应用程序的用户而言,回车后下移焦点到下一个编辑组件中的小功能,是非常贴心的,利用flex中的KEY_DOWN事件可以方便的实现回车下移焦点,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="CreationComplete()" height="398" width="518" backgroundColor="#E6E3E3">
<mx:Script>
<!--[CDATA[
import mx.containers.HBox;
import mx.core.UIComponent;
import mx.events.CloseEvent;
import mx.controls.Alert;
public function CreationComplete():void{
var monthNames:Array=new Array;
var dayNames:Array=new Array;
monthNames.push("一","二","三","四","五","六","七","八","九","十","十一","十二");
dayNames.push("日","一","二","三","四","五","六");
this.edtccrq.monthNames = monthNames;//中文月份名
this.edtgrrq.monthNames = monthNames;
this.edtrzrq.monthNames = monthNames;
this.edtccrq.dayNames = dayNames;//中文星期名
this.edtgrrq.dayNames = dayNames;
this.edtrzrq.dayNames = dayNames;
this.edtccrq.formatString = "YYYY-MM-DD";//本地日期格式
this.edtgrrq.formatString = "YYYY-MM-DD";;
this.edtrzrq.formatString = "YYYY-MM-DD";
//以下批量添加事件监视
var childs:Array= this.mainvbox.getChildren();
//取出顶级对象的子组件集合
var item:Object;
for each (item in childs){
if (item is HBox){
var items:Array = (item as HBox).getChildren();
//取出HBox中的子组合集合
var subitem:Object;
for each (subitem in items){
if (subitem is UIComponent) {
(subitem as UIComponent).addEventListener(KeyboardEvent.KEY_DOWN,this.onKeyDown);
//给组件注册KEY_DOWN事件。
}
}
}
}
}
private function btncloseclick():void{
this.parentApplication.panelassetedit.visible=false;
this.paren
相关文档:
通过Flex中的Timer可是实现数字时钟的效果,其效果图如下:
实现的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<!--[CDATA[
import mx.formatters.DateFormatt ......
http://www.noupe.com/adobe/flex-developers-toolbox-free-components-themes-and-tutorials.html经典中的经典
http://www.efflex.org/EfflexExplorer.html堪称经典
http://mofeichen.javaeye.com/blog/466171里面有好多特效例子
http://www.marcusschiesser.de/?p=67 3D相册,还不错
http://www.switchont ......
DisplayShelf.as文件如下:
package file
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
import flash. ......
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
......
通常大家都会设置visible属性为false。但这样做还是会有问题:组件仍然占用原来的位置。
最后同时使用includeInLayout与visible属性来解决。
实现效果图如下:
实现的效果是当点击hide text的时候,中间文字将消失,同时show text按钮自动向上移动对齐(因为Application的layout属性为vertical)
......