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 (btnMc.getChildAt(i).alpha == 1) { answerArr.push(i); } } if (answerArr.length == btnMc.numChildren/2) { btnMc.removeEventListener(MouseEvent.CLICK,onBtn); nextBtn.removeEventListener(MouseEvent.CLICK,onNextBtn); thisMc.nextFrame(); } else { answerArr = []; } trace(answerArr); } } }
//答案
private var arr2:Array = [0,3,5,6]; public function Answer2(_mc:MovieClip ) { for (var j:uint=0; j<_mc["diMc"].numChildren; j++) { _mc["diMc"].getChildAt(j).alpha = 0; } for (var i:uint=0; i<SecondFrame.answerArr.length; i++) { _mc["answerMc"].getChildAt(i).alpha = 0; _mc["diMc"].getChildAt(SecondFrame.answerArr[i]).alpha = 1; if (SecondFrame.answerArr[i] == arr2[i]) { funnum1(); } else { _mc["right"].nextFrame(); _mc["answerMc"].getChildAt(i).alpha = 1; } } }