as3.0 选择题2
package com{ import flash.display.MovieClip; import flash.display.SimpleButton; import flash.events.MouseEvent; import flash.text.TextField; import flash.system.fscommand; public class FristFrame extends MovieClip { private var thisMc:MovieClip; private var txtMc:MovieClip; private var btnMc:MovieClip; public static var answerArr:Array=[]; private var arr:Array=["A","B","C","D"]; private var nextBtn:SimpleButton; public function FristFrame(_thisMc:MovieClip,_txtMc:MovieClip,_btnMc:MovieClip) { thisMc=_thisMc; txtMc=_txtMc; btnMc=_btnMc; btnMc.addEventListener(MouseEvent.CLICK,onBtn); for (var i:uint =0; i<txtMc.numChildren; i++) { var txt:TextField=txtMc.getChildAt(i) as TextField; btnMc.getChildAt(i).alpha=0; txt.text=""; } txtMc.addEventListener(MouseEvent.CLICK,onTxt); } private function onTxt(e:MouseEvent) { e.target.text=""; } private function onBtn(e:MouseEvent) { for (var i:uint=0; i<btnMc.numChildren; i++) { if (e.target.name==btnMc.getChildAt(i).name) { var txt0:TextField; var txt1:TextField; var str:String; var j:uint; if (i%2==0) { str="A"; j=i; } else { str="B"; j=i-1; } var num:Number=j+2; for (j; j<num; j++) { var txt:TextField=txtMc.getChildAt(j) as TextField; if (txt.text==""&&j!=num) { txt.text=str; return; } } } } } public function nextFun(_nextBtn:SimpleButton ) { nextBtn=_nextBtn; nextBtn.addEventListener(MouseEvent.CLICK,onNextBtn); } private function onNextBtn(e:MouseEvent) { thisMc.nextFrame(); txtMc.removeEventListener(MouseEvent.CLICK,onTxt); nextBtn.removeEventListener(MouseEvent.CLICK,onNextBtn); for (var i:uint =0; i<txtMc.numChildren; i++) { var txt:TextField=txtMc.getChildAt(i) as TextField; answerArr.push(txt.text); } } } }
posted on 2020-03-10 17:14 zqiang0803 阅读(229) 评论(0) 编辑 收藏 举报