Dzwebs.Net

撰写电脑技术杂文十余年

Flash中的_xmouse

Admin | 2012-3-12 9:26:00 | 被阅次数 | 7717

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

  下面的示例显示舞台的 xmouse 位置,以及一个放在舞台上的名为 my_btn 的按钮。在时间轴的第 1 帧中输入下面的 ActionScript:

  this.createTextField("mouse_txt", 999, 5, 5, 150, 40);
  mouse_txt.html = true;
  mouse_txt.wordWrap = true;
  mouse_txt.border = true;
  mouse_txt.autoSize = true;
  mouse_txt.selectable = false;
  //
  var mouseListener:Object = new Object();
  mouseListener.onMouseMove = function() {
      var table_str:String = "<textformat tabstops='[50,100]'>";
      table_str += "<b>Stage</b>\t"+"x:"+_xmouse+"\t"+"y:"+_ymouse+newline;
      table_str += "<b>Button</b>\t"+"x:"+my_btn._xmouse+"\t"+"y:"+my_btn._ymouse+newline;
      table_str += "</textformat>";
      mouse_txt.htmlText = table_str;
  };
  Mouse.addListener(mouseListener);

  以下示例返回舞台 (_level0) 上鼠标的当前 x 和 y 坐标以及相对于舞台上名为 my_mc 的影片剪辑的坐标:

  this.createTextField("mouse_txt", this.getNextHighestDepth(), 0, 0, 150, 66);
  mouse_txt.html = true;
  mouse_txt.multiline = true;
  var row1_str:String = "&nbsp;\t<b>_xmouse\t</b><b>_ymouse</b>";
  my_mc.onMouseMove = function() {
      mouse_txt.htmlText = "<textformat tabStops='[50,100]'>";
      mouse_txt.htmlText += row1_str;
      mouse_txt.htmlText += "<b>_level0</b>\t"+_xmouse+"\t"+_ymouse;
      mouse_txt.htmlText += "<b>my_mc</b>\t"+this._xmouse+"\t"+this._ymouse;
      mouse_txt.htmlText += "</textformat>";
  };

  下面的示例在舞台上创建三个文本字段。mouse_txt 实例显示鼠标相对于舞台的当前位置。textfield_txt 实例显示鼠标指针相对于 my_txt 实例的当前位置。请将以下 ActionScript 添加到 FLA 或 AS 文件:

  this.createTextField("mouse_txt", this.getNextHighestDepth(), 10, 10, 200, 22);
  mouse_txt.border = true;
  this.createTextField("textfield_txt", this.getNextHighestDepth(), 220, 10, 200, 22);
  textfield_txt.border = true;
  this.createTextField("my_txt", this.getNextHighestDepth(), 100, 100, 160, 120);
  my_txt.border = true;

  var mouseListener:Object = new Object();
  mouseListener.onMouseMove = function() {
      mouse_txt.text = "MOUSE ... X:" + Math.round(_xmouse) + ",\tY:" + Math.round(_ymouse);
      textfield_txt.text = "TEXTFIELD ... X:" + Math.round(my_txt._xmouse) + ",\tY:" +
      Math.round(my_txt._ymouse);
  }

  Mouse.addListener(mouseListener);


该杂文来自: 动画制作杂文

上一篇:flash的._xscale介绍

下一篇:Flash _ymouse

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计