flex2里自定义日期输入控件
时间:2007-04-19 来源:qzc
gbDate.as文件
package fun{
import mx.controls.*;
public class gbDate extends DateField
{
public function gbDate():void
{
formatString="YYYY-MM-DD";
}
public function getDateStr():String
{
var dt:String;
dt =DateField.dateToString( selectedDate,"YYYY-MM-DD");
return dt;
}
}
}
测试文件gbDate.mxsml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
fontFamily="宋体" fontSize="14" xmlns:tx="fun.*">
<mx:Script>
<![CDATA[
public function showdate():void
{
msg.text=cdate.getDateStr();
}
]]>
</mx:Script>
<mx:TitleWindow width="404" height="317" layout="absolute" title="日期选择">
<mx:Button x="69" y="210" label="Button" click="showdate()"/>
<mx:Label x="69" y="121" id="msg" text="Label"/>
<tx:gbDate x="69" y="36" id="cdate" close="showdate()" />
<mx:DateField x="145" y="119" id="mdate" formatString="YYYY-MM-DD" />
</mx:TitleWindow>
</mx:Application>
package fun{
import mx.controls.*;
public class gbDate extends DateField
{
public function gbDate():void
{
formatString="YYYY-MM-DD";
}
public function getDateStr():String
{
var dt:String;
dt =DateField.dateToString( selectedDate,"YYYY-MM-DD");
return dt;
}
}
}
测试文件gbDate.mxsml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
fontFamily="宋体" fontSize="14" xmlns:tx="fun.*">
<mx:Script>
<![CDATA[
public function showdate():void
{
msg.text=cdate.getDateStr();
}
]]>
</mx:Script>
<mx:TitleWindow width="404" height="317" layout="absolute" title="日期选择">
<mx:Button x="69" y="210" label="Button" click="showdate()"/>
<mx:Label x="69" y="121" id="msg" text="Label"/>
<tx:gbDate x="69" y="36" id="cdate" close="showdate()" />
<mx:DateField x="145" y="119" id="mdate" formatString="YYYY-MM-DD" />
</mx:TitleWindow>
</mx:Application>
相关阅读 更多 +