二选一,好几个二
package com{
import flash.display.MovieClip; import flash.events.MouseEvent; import flash.display.SimpleButton; import flash.display.Stage; import flash.geom.Point; import flash.text.TextField; public class SecondFrame extends MovieClip { private var thisMc:MovieClip; private var btnMc:MovieClip; public static var answerArr:Array=[]; public function SecondFrame(_thisMc:MovieClip,_btnMc:MovieClip ) { thisMc=_thisMc; btnMc=_btnMc; btnMc.buttonMode=true; btnMc.addEventListener(MouseEvent.CLICK,onBtn); for (var i:uint=0; i<btnMc.numChildren; i++) { btnMc.getChildAt(i).alpha=0; } } private function onBtn(e:MouseEvent) { e.target.alpha=1; for (var i:uint=0; i<btnMc.numChildren; i++) { if (e.target.name==btnMc.getChildAt(i).name) { if (i%2==0) { btnMc.getChildAt(i+1).alpha=0; } else { btnMc.getChildAt(i-1).alpha=0; } } } } private var nextBtn:SimpleButton; public function nextFun(_nextBtn:SimpleButton ) { nextBtn=_nextBtn; nextBtn.addEventListener(MouseEvent.CLICK,onNextBtn); } private function onNextBtn(e:MouseEvent) { for (var i:uint=0; i<btnMc.numChildren; i++) { if (i%2==0) { if (btnMc.getChildAt(i).alpha==1) { answerArr.push(i); } else if (btnMc.getChildAt(i+1).alpha==1) { answerArr.push(i+1); }else{ answerArr.push(); } } } trace(answerArr); btnMc.removeEventListener(MouseEvent.CLICK,onBtn); nextBtn.removeEventListener(MouseEvent.CLICK,onNextBtn); thisMc.nextFrame(); } } }
//答案 private var arr2:Array=[0,3]; public function Answer2(_mc:MovieClip ) { for (var j:Number=0; j<_mc["diMc"].numChildren; j++) { _mc["diMc"].getChildAt(j).alpha=0; } for (var i:Number=0; i<arr2.length; i++) { _mc["answerMc"].getChildAt(i).alpha=0; if (SecondFrame.answerArr[i]!=undefined) { _mc["diMc"].getChildAt(SecondFrame.answerArr[i]).alpha=1; } if (SecondFrame.answerArr[i]==arr2[i]) { funnum0(); } else { _mc["right"].nextFrame(); _mc["answerMc"].getChildAt(i).alpha=1; } } }
posted on 2019-04-08 09:10 zqiang0803 阅读(127) 评论(0) 编辑 收藏 举报