qilly123578
路人甲
路人甲
  • 注册日期2008-10-29
  • 发帖数1
  • QQ
  • 铜币108枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1781回复:2

向高手求教

楼主#
更多 发布于:2010-04-15 21:37
今天做论文,遇到了一个我一下午都没有解决的问题,在flash中同一个层的两个按钮功能出现了交叉影响,两个按钮的功能分别是移动和测距,具体代码如下:<BR>测距:on (release) <BR>{<BR> measure();//调用measure()函数<BR> function measure()<BR> {//定义measure()函数     <BR>  var chuzhoushi_mc:MovieClip = this.createEmptyMovieClip("chuzhoushi_mc",this.getNextHighestDepth());//创建名为“chuzhoushi_mc”的影片剪辑<BR>  var mouseListener:Object = new Object();//建立一个mouseListener侦听器对象<BR>  mouseListener.onMouseDown = function()<BR>  {//当鼠标左键按下时<BR>   <BR>   this.target_mc.clear();<BR>   this.target_mc['length'+nextDepth+'_txt'].text = "";<BR>   this.isDrawing = true;//开始画线<BR>   this.orig_x = _xmouse;//记录此时的鼠标指针的X坐标<BR>   this.orig_y = _ymouse;//记录此时的鼠标指针的Y坐标<BR>   this.target_mc = chuzhoushi_mc.createEmptyMovieClip("",chuzhoushi_mc.getNextHighestDepth());<BR>  }<BR>  mouseListener.onMouseMove = function()<BR>  {//当鼠标移动时<BR>   if(this.isDrawing)<BR>   {//当开始画线时 <BR>    this.target_mc.clear();//清除上一次所画的线条<BR>    this.target_mc.lineStyle(1,0xFF0000,100);//设定线条的式样<BR>    this.target_mc.moveTo(this.orig_x,this.orig_y);//设定所画线条的起点 <BR>    this.target_mc.lineTo(_xmouse,_ymouse);//设定所画线条的终点    <BR>   }   <BR>   updateAfterEvent();<BR>  }<BR>  mouseListener.onMouseUp = function()<BR>  {//当鼠标左键释放时<BR>   line_width = _xmouse-this.orig_x;//画线终点与原点X轴坐标的距离<BR>   line_height = _ymouse-this.orig_y;//画线终点与原点Y轴坐标的距离<BR>   this.isDrawing = false; //停止画线<BR>   var l:Number = Math.sqrt (Math.pow (line_width,2)+Math.pow (line_height,2))*4250/map_mc._xscale; //计算出线条的长度,并换算成实际长度 <BR>   this.target_mc.createTextField("length"+nextDepth+"_txt",chuzhoushi_mc.getNextHighestDepth(),(this.orig_x+_xmouse)/2-10,(this.orig_y+_ymouse)/2-20,600,200);//创建文本框,以显示所测量的长度结果<BR>   var myTest:String = "两点之间的距离为 :";<BR>   //myTest.color = 0xFF0000;<BR>   this.target_mc['length'+nextDepth+'_txt'].text = myTest + Math.round (l) + "m";//显示测量结果<BR>   //this.isDrawing = false;<BR>  }<BR>  //mouseListener.onMouseUp = function()<BR>  //{<BR>  //this.isDrawing = false;<BR>  //}<BR>  //this.target_mc.clear();<BR>  Mouse.addListener(mouseListener);<BR> }<BR>}<BR>移动: on (release) {//鼠标释放时的动作<BR>  move();<BR>  //调用move()函数<BR>  function move() {<BR>   //定义move()函数<BR>         map_mc.onMouseDown = function() {<BR>          //当鼠标左键按下时<BR>          startDrag(map_mc);<BR>          //开始拖动地图<BR>         }<BR>         map_mc.onMouseUp = function() {<BR>          //当鼠标左键释放时<BR>          stopDrag();<BR>          //停止拖动地图    <BR>         }<BR>    }<BR> }<BR>有哪位高人帮忙解决一下!
喜欢0 评分0
游客

返回顶部