什么都不写了,直接贴代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:local="cn.whitecrystal.util.*">
<mx:Script>
<![CDATA[
]]>
</mx:Script>
<mx:Form id="register">
<mx:FormItem label="用户名:">
<mx:TextInput id="nametext"/>
</mx:FormItem>
<mx:FormItem label="昵称:">
<mx:TextInput id="name_nc"/>
</mx:FormItem>
<mx:FormItem label="密码:">
<mx:TextInput displayAsPassword="true" id="paswod"/>
</mx:FormItem>
<mx:FormItem label="邮箱:">
<mx:TextInput id="email"/>
</mx:FormItem>
<mx:FormItem label="身份证号:">
<mx:TextInput id="pid"/>
</mx:FormItem>
<mx:HBox width="100%" horizontalAlign="center">
<local:ResetButton label="reset" target="{register}"/>
</mx:HBox>
</mx:Form>
</mx:Application>
这个是reset按钮组件
package cn.whitecrystal.util
{
import flash.events.MouseEvent;
import mx.containers.Form;
import mx.containers.FormItem;
import mx.controls.Button;
public class ResetButton extends Button
{
private var _target:Object;
public function ResetButton()
{
super();
this.addEventListener(MouseEvent.CLICK,onReset);
}
private function onReset(event:MouseEvent):void
{
var form:Form=target as Form;
for each (var formItem:Object in form.getChildren() )
{
if(formItem is FormItem)
{
(formItem as FormItem).getChildren()[0].text="";
}
}
}
public function set target(value:Object):void
{
this._target=value;
}
public function get target():Object
{
return this._target;
}
}
}