组件的综合应用

 

tj_btn.addEventListener(MouseEvent.CLICK,tj);
reset_btn.addEventListener(MouseEvent.CLICK,reset);

function tj(e:MouseEvent)
{
  //appendText方法用于实现在多行文本中追加内容
  output_txt.appendText("姓名:"+username.text+"\n");
 
  if(male.selected==true)
    output_txt.appendText("性别:"+male.label+"\n");
  else
    output_txt.appendText("性别:"+female.label+"\n");
 
  output_txt.appendText("家庭住址:"+combo1.text+"\n");
  output_txt.appendText("职业:"+list1.selectedItem.label+"\n");
 
  output_txt.appendText("爱好:");
  if(check1.selected==true)
    output_txt.appendText(check1.label+" ");
  if(check2.selected==true)
    output_txt.appendText(check2.label+" ");
  if(check3.selected==true)
    output_txt.appendText(check3.label+" ");
  if(check4.selected==true)
    output_txt.appendText(check4.label+" ");
  if(check5.selected==true)
    output_txt.appendText(check5.label+" ");
  if(check6.selected==true)
    output_txt.appendText(check6.label+" ");
}

function reset(e:MouseEvent)
{
  username.text="";
  male.selected=true;
  combo1.selectedIndex=-1;  //设置下拉列表中不选任何项
  list1.selectedIndex=-1;   //设置列表框中不选任何项
  check1.selected=false;
  check2.selected=false;
  check3.selected=false;
  check4.selected=false;
  check5.selected=false;
  check6.selected=false;
  output_txt.text="";
 }
 

posted on 2012-10-26 22:14  笔墨丹青  阅读(195)  评论(0)    收藏  举报

导航