标签:ddc geo global icm mouse one xtend rap extends
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; public class Line 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 downName:String=null; private var point:Point; private var newPoint:Point; private var eTarMc:MovieClip; private var mcArr:Array=[]; private var McArr:Array=[]; private var musicArr:Array=["","恭喜你,都连对了","","正确"]; private var mm:MyMusic=new MyMusic ; public function Line(_wordMc:MovieClip,_picMc:MovieClip,_emptyMc:MovieClip,_color:uint=0xFF0000,_size:uint=5) { wordMc=_wordMc; picMc=_picMc; emptyMc=_emptyMc; color=_color; size=_size; clearDeaw(); MyMusic.initialSound(musicArr[0]); 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); if (eTarMc.alpha==0) { eTarMc.alpha=1; mcArr.push(e.target); McArr.push(e.currentTarget); if ((downName==null)) { downName=e.target.name.slice(0,2); line=new Shape ; emptyMc.addChild(line); line.graphics.lineStyle(size,color); if (e.target.name.slice(0,2)=="wo") { line.graphics.moveTo(newPoint.x+e.target.width/2,newPoint.y+e.target.height); } else if (e.target.name.slice(0,2)=="pi") { line.graphics.moveTo(newPoint.x+e.target.width/2,newPoint.y); } } else if ((downName!=e.target.name.slice(0,2))) { if (e.target.name.slice(0,2)=="wo") { line.graphics.lineTo(newPoint.x+e.target.width/2,newPoint.y+e.target.height); } else if (e.target.name.slice(0,2)=="pi") { line.graphics.lineTo(newPoint.x+e.target.width/2,newPoint.y); } if (mcArr[0].name.slice(-1)==mcArr[1].name.slice(-1)||McArr[0].name==McArr[1].name) { if (emptyMc.numChildren==5) { MyMusic.initialSound(musicArr[1]); explainMc.gotoAndStop(3); } MyMusic.initialSound(musicArr[3]); } else { line.graphics.clear(); emptyMc.removeChild(line); McArr[0][mcArr[0].name].alpha=0; McArr[1][mcArr[1].name].alpha=0; MyMusic.initialSound(musicArr[2]); } mcArr=[]; McArr=[]; downName=null; } else { line.graphics.clear(); emptyMc.removeChild(line); McArr[1][mcArr[1].name].alpha=0; McArr[0][mcArr[0].name].alpha=0; mcArr=[]; McArr=[]; downName=null; } } } //弹框 private var explainMc:MovieClip; public function explainFun(_explainMc:MovieClip) { explainMc=_explainMc; explainMc.gotoAndStop(2); explainMc.addEventListener(MouseEvent.CLICK,onExplain); } private function onExplain(e:MouseEvent) { if (e.target.name=="startGameBtn") { explainMc.gotoAndStop(1); MyMusic.pauseFuntion(); } else if (e.target .name=="againBtn") { explainMc.gotoAndStop(1); MyMusic.pauseFuntion(); clearDeaw(); } } public function clearDeaw() { while (emptyMc.numChildren>0) { emptyMc.removeChildAt(0); } mcArr=[]; McArr=[]; downName=null; for (var i:uint=0; i<picMc.numChildren; i++) { picMc.getChildAt(i).alpha=0; wordMc.getChildAt(i).alpha=0; } } } }
标签:ddc geo global icm mouse one xtend rap extends
原文地址:https://www.cnblogs.com/zqiang0803/p/9190903.html