package{ import flash.display.MovieClip; import fl.controls.*; import flash.text.TextField; import flash.events.*; public class RadioButtonMain extends MovieClip { private var radio1:RadioButton; private var radio2:RadioButton; private var radio3:RadioButton; private var radio4:RadioButton; private var radio5:RadioButton; private var radio6:RadioButton; private var radio7:RadioButton; private var radio8:RadioButton; private var radio9:RadioButton; private var radio10:RadioButton; private var radio11:RadioButton; private var radio12:RadioButton; private var radio13:RadioButton; private var radio14:RadioButton; private var radio15:RadioButton; private var radio16:RadioButton; private var Button_tj:Button; private var zu1:RadioButtonGroup; private var zu2:RadioButtonGroup; private var zu3:RadioButtonGroup; private var zu4:RadioButtonGroup; private var tf1:TextField; private var tf2:TextField; private var tf3:TextField; private var tf4:TextField; private var tf5:TextField; private var tf6:TextField; private var tf7:TextField; private var tf8:TextField; private var tf9:TextField; private var tf10:TextField; private var tf11:TextField; private var tf12:TextField; private var tf13:TextField; private var tf14:TextField; private var tf15:TextField; private var tf16:TextField; private var tf17:TextField; private var tf18:TextField; private var tf19:TextField; private var tf20:TextField; private var tf21:TextField; private var tf22:TextField; private var tffs:TextField; public function RadioButtonMain() { radio1=new RadioButton(); radio2=new RadioButton(); radio3=new RadioButton(); radio4=new RadioButton(); radio5=new RadioButton(); radio6=new RadioButton(); radio7=new RadioButton(); radio8=new RadioButton(); radio9=new RadioButton(); radio10=new RadioButton(); radio11=new RadioButton(); radio12=new RadioButton(); radio13=new RadioButton(); radio14=new RadioButton(); radio15=new RadioButton(); radio16=new RadioButton(); Button_tj = new Button(); zu1=new RadioButtonGroup("1"); zu2=new RadioButtonGroup("2"); zu3=new RadioButtonGroup("3"); zu4=new RadioButtonGroup("4"); Button_tj.addEventListener(MouseEvent.CLICK,onClickHandler); tf1 = new TextField(); tf1.text = "一:单选题"; tf1.x = 30; tf1.y = 10; tf1.width = 100; addChild(tf1); tf2 = new TextField(); tf2.text = "请选择以下正确的陈述:"; tf2.x = 30; tf2.y = 30; tf2.width = 200; addChild(tf2); tf3 = new TextField(); /*对*/ tf3.text = "ActionScript3.0的运行环境是AVM2"; tf3.x = 60; tf3.y = 52; tf3.width = 200; addChild(tf3); tf4 = new TextField(); tf4.text = "ActionScript3.0的运行环境是JVM"; tf4.x = 60; tf4.y = 72; tf4.width = 200; addChild(tf4); tf5 = new TextField(); tf5.text = "MovieClip类是display类的子类"; tf5.x = 60; tf5.y = 92; tf5.width = 200; addChild(tf5); tf6 = new TextField(); tf6.text = "Sprite类是MovieClip类的子类"; tf6.x = 60; tf6.y = 112; tf6.width = 200; addChild(tf6); tf7 = new TextField(); tf7.text = "下列对类的继承关系描述错误的是:"; tf7.x = 30; tf7.y = 132; tf7.width = 200; addChild(tf7); tf8 = new TextField(); tf8.text = "Bitmap -> DisplayObject -> EventDispatcher -> Object"; tf8.x = 60; tf8.y = 152; tf8.width = 400; addChild(tf8); tf9 = new TextField(); /*错*/ tf9.text = "Shape -> Sprite -> DisplayObject -> EventDispatcher"; tf9.x = 60; tf9.y = 172; tf9.width = 400; addChild(tf9); tf10 = new TextField(); tf10.text = "Graphics-> Object"; tf10.x = 60; tf10.y = 192; tf10.width = 400; addChild(tf10); tf11 = new TextField(); tf11.text = "Label -> UIComponent -> Sprite -> DisplayObject"; tf11.x = 60; tf11.y = 212; tf11.width = 400; addChild(tf11); tf13 = new TextField(); tf13.text = "以下哪个类不在flash.display包中"; tf13.x = 30; tf13.y = 252; tf13.width = 400; addChild(tf13); tf14 = new TextField(); /*对*/ tf14.text = "Event"; tf14.x = 60; tf14.y = 272; tf14.width = 400; addChild(tf14); tf15 = new TextField(); tf15.text = "SimpleButton"; tf15.x = 60; tf15.y = 292; tf15.width = 400; addChild(tf15); tf16 = new TextField(); tf16.text = "Rectagle"; tf16.x = 60; tf16.y = 312; tf16.width = 400; addChild(tf16); tf17 = new TextField(); tf17.text = "BitmapData"; tf17.x = 60; tf17.y = 332; tf17.width = 400; addChild(tf17); tf18 = new TextField(); tf18.text = "下列对类的继承关系描述正确的是:"; tf18.x = 30; tf18.y = 352; tf18.width = 400; addChild(tf18); tf19 = new TextField(); /*对*/ tf19.text = "Bitmap -> DisplayObject -> EventDispatcher -> Object"; tf19.x = 60; tf19.y = 372; tf19.width = 400; addChild(tf19); tf20 = new TextField(); tf20.text = "Shape -> Sprite -> DisplayObject -> EventDispatcher"; tf20.x = 60; tf20.y = 392; tf20.width = 400; addChild(tf20); tf21 = new TextField(); tf21.text = "Graphics-> Event"; tf21.x = 60; tf21.y = 412; tf21.width = 400; addChild(tf21); tf22 = new TextField(); tf22.text = "TextField -> UIComponent -> Sprite -> DisplayObject"; tf22.x = 60; tf22.y = 432; tf22.width = 400; addChild(tf22); tffs = new TextField(); tffs.text = ""; tffs.x = 250; tffs.y = 462; tffs.width = 88; tffs.height = 33; tffs.border = true; addChild(tffs); radio1.move(30,50); radio2.move(30,70); radio3.move(30,90); radio4.move(30,110); radio5.move(30,150); radio6.move(30,170); radio7.move(30,190); radio8.move(30,210); radio9.move(30,270); radio10.move(30,290); radio11.move(30,310); radio12.move(30,330); radio13.move(30,370); radio14.move(30,390); radio15.move(30,410); radio16.move(30,430); Button_tj.move(66,462); radio1.label = ""; radio2.label = ""; radio3.label = ""; radio4.label = ""; radio5.label = ""; radio6.label = ""; radio7.label = ""; radio8.label = ""; radio9.label = ""; radio10.label = ""; radio11.label = ""; radio12.label = ""; radio13.label = ""; radio14.label = ""; radio15.label = ""; radio16.label = ""; Button_tj.width = 66; Button_tj.height = 33; Button_tj.label = "提交"; addChild(radio1); addChild(radio2); addChild(radio3); addChild(radio4); addChild(radio5); addChild(radio6); addChild(radio7); addChild(radio8); addChild(radio9); addChild(radio10); addChild(radio11); addChild(radio12); addChild(radio13); addChild(radio14); addChild(radio15); addChild(radio16); addChild(Button_tj); zu1.addRadioButton(radio1); zu1.addRadioButton(radio2); zu1.addRadioButton(radio3); zu1.addRadioButton(radio4); zu2.addRadioButton(radio5); zu2.addRadioButton(radio6); zu2.addRadioButton(radio7); zu2.addRadioButton(radio8); zu3.addRadioButton(radio9); zu3.addRadioButton(radio10); zu3.addRadioButton(radio11); zu3.addRadioButton(radio12); zu4.addRadioButton(radio13); zu4.addRadioButton(radio14); zu4.addRadioButton(radio15); zu4.addRadioButton(radio16); zu1.addEventListener(Event.CHANGE,onChange1Handler); zu2.addEventListener(Event.CHANGE,onChange2Handler); zu3.addEventListener(Event.CHANGE,onChange3Handler); zu4.addEventListener(Event.CHANGE,onChange4Handler); } private function onChange1Handler(e):void { var rg:RadioButtonGroup = e.target as RadioButtonGroup; switch (rg.selection) { case radio1 : break; case radio2 : break; case radio3 : break; case radio4 : break; } } private function onChange2Handler(e):void { var rg1:RadioButtonGroup = e.target as RadioButtonGroup; switch (rg1.selection) { case radio5 : break; case radio6 : break; case radio7 : break; case radio8 : break; } } private function onChange3Handler(e):void { var rg2:RadioButtonGroup = e.target as RadioButtonGroup; switch (rg2.selection) { case radio9 : break; case radio10 : break; case radio11 : break; case radio12 : break; } } private function onChange4Handler(e):void { var rg3:RadioButtonGroup = e.target as RadioButtonGroup; switch (rg3.selection) { case radio13 : break; case radio14 : break; case radio15 : break; case radio16 : break; } } private function onClickHandler(e:MouseEvent):void { var fen:uint; var fen1:uint; var fen2:uint; var fen3:uint; var fen4:uint; if(radio1.selected == true) { fen1 = 25; } else { fen1 = 0; } if(radio6.selected == true) { fen2 = 25; } else { fen2 = 0; } if(radio9.selected == true) { fen3 = 25; } else { fen3 = 0; } if(radio13.selected == true) { fen4 = 25; } else { fen4 = 0; } trace(fen1); trace(fen2); trace(fen3); trace(fen4); fen = fen1+fen2+fen3+fen4; trace(fen); tffs.text = String(fen); } }}
附带判断得分程序。