连线有答案
package com{ import flash.display.MovieClip; import flash.display.Shape; import flash.events.MouseEvent; import fl.motion.Color; import flash.events.Event; import flash.geom.Point; import flash.display.SimpleButton; public class FouthFrame extends MovieClip { private var picMc:MovieClip; private var wordMc:MovieClip; private var emptyMc:MovieClip; private var color:uint; private var size:uint; private var line:Shape; private var point:Point; private var newPoint:Point; private var eTarMc:MovieClip; private var mcArr:Array=[]; private var McArr:Array=[]; private var wordMusicArr:Array=[""]; private var picMusicArr:Array=[""]; public static var answerArr:Array=[]; public function FouthFrame(_wordMc:MovieClip,_picMc:MovieClip,_emptyMc:MovieClip,_color:uint=0xFF0000,_size:uint=5) { wordMc=_wordMc; picMc=_picMc; emptyMc=_emptyMc; color=_color; size=_size; picMc.buttonMode=true; wordMc.buttonMode=true; wordMc.addEventListener(MouseEvent.MOUSE_DOWN,onDown); picMc.addEventListener(MouseEvent.MOUSE_DOWN,onDown); } private function onDown(e:MouseEvent) { eTarMc=e.target as MovieClip; point=new Point(e.target.x,e.target.y); newPoint=e.currentTarget.localToGlobal(point); var n:int=int(e.target.name.slice(-1))-1; if (eTarMc.alpha==0) { eTarMc.alpha=1; mcArr.push(e.target); McArr.push(e.currentTarget); if (McArr.length==1) { line=new Shape ; emptyMc.addChild(line); line.graphics.lineStyle(size,color); line.graphics.moveTo(newPoint.x,newPoint.y); } else if (McArr[0]==McArr[1]&&McArr.length==2) { line.graphics.moveTo(newPoint.x,newPoint.y); mcArr[0].alpha=0; McArr.shift(); mcArr.shift(); } else if (McArr[0]!=McArr[1]&&McArr.length ==2) { line.graphics.lineTo(newPoint.x,newPoint.y); for (var i:uint=0; i<mcArr.length; i++) { answerArr.push(mcArr[i].name); } mcArr=[]; McArr=[]; } else if (mcArr[0].name.slice(-1)!=mcArr[1].name.slice(-1)) { mcArr[0].alpha=0; mcArr[1].alpha=0; mcArr=[]; McArr=[]; emptyMc.removeChild(line); } } } private var nextBtn:SimpleButton; public function nextFun(_nextBtn:SimpleButton ) { nextBtn=_nextBtn; nextBtn.addEventListener(MouseEvent.CLICK,onNextBtn); } private function onNextBtn(e:MouseEvent) { if (emptyMc.numChildren==wordMc.numChildren) { MovieClip(nextBtn.parent).nextFrame(); nextBtn.removeEventListener(MouseEvent.CLICK,onNextBtn); } } } }
private var arr4:Array = []; public function Answer4(_mc:MovieClip,emptyMc:MovieClip) { arr4 = FouthFrame.answerArr; //_mc["answerMc"].visible=false; for (var i:uint=0; i<arr4.length; i++) { if (i%2==0) { if (arr4[i].slice(-1) != arr4[i + 1].slice(-1)) { _mc["right"].nextFrame(); } else { funnum0(); } DrawLine.LineStart(_mc[arr4[i]].x,_mc[arr4[i]].y); DrawLine.LineStop(_mc[arr4[i+1]].x,_mc[arr4[i+1]].y,emptyMc); } } }
//画线 package com{ import flash.display.MovieClip; import flash.display.Shape; public class DrawLine extends MovieClip { public static var shape:Shape; public function DrawLine() { // constructor code } public static function LineStart(startX:Number,startY:Number) { shape=new Shape(); shape.graphics.lineStyle(3,0x9F3D1B,1); shape.graphics.moveTo(startX,startY); } public static function LineStop(stopX:Number,stopY:Number,emptyMc:MovieClip) { shape.graphics.lineTo(stopX,stopY); emptyMc.addChild(shape) } } }
posted on 2019-04-16 11:11 zqiang0803 阅读(216) 评论(0) 编辑 收藏 举报