鼠标拉框批量操作影片剪辑

2008-04-02 10:31:27来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


  //此为测试程式,因此只显示了效果,以下为AS脚本----------------------------------

  stageL = 0;

  stageT = 30;

  stageR = Stage.width;

  stageB = Stage.height;

  //以上为初始化选区范围;

  var my_mc = new Array();

  //创建用于存储mc的数组;

  onload();

  reload_btn.onRelease = function() {

  onload();

  };

  function onload() {

  for (i=1; i<10; i ) {

  test0.duplicateMovieClip("test" i, i);

  }

  for (i=0; i<10; i ) {

  my_mc.push(eval("test" i));

  tests = eval("test" i);

  tests._alpha = 100;

  tests._x = random(200) 100;

  tests._y = random(200) 100;

  }

  }

  //初始化动画元素;

  var mouseObj = new Object();

  Mouse.addListener(mouseObj);

  //监听鼠标事件;

  mouseObj.onMouseDown = function() {

  if (_xmouse>stageL && _xmouse<stageR && _ymouse>stageT && _ymouse<stageB) {

  box_x = _xmouse;

  box_y = _ymouse;

  createEmptyMovieClip("box_mc", 50);

  with (box_mc) {

  lineStyle(1, 0xff0000, 80);

  beginFill(0xff0000, 10);

  moveTo(0, 0);

  lineTo(0, 1000);

  lineTo(1000, 1000);

  lineTo(1000, 0);

  lineTo(0, 0);

  endFill();

  _width = 1;

  _height = 1;

  }

  box_mc.onEnterFrame = function() {

  this._width = Math.abs(_xmouse-box_x);

  this._height = Math.abs(_ymouse-box_y);

  this._x = _xmouse<box_x ? _xmouse : box_x;

  this._y = _ymouse<box_y ? _ymouse : box_y;

  };

  }

  };

  //以上为在选区范围内创建选框;

  mouseObj.onMouseUp = function() {

  //本函数为处理选框范围内的数据;

  if (box_mc != undefined) {

  //假如选框以被构造边执行control函数;

  control();

  box_mc.removeMovieClip();

  }

  };

  function control() {

  for (i=0; i<my_mc.length; i ) {

  if (box_mc.hitTest(my_mc[i])) {

  //以下程式为操作在选框范围内或和选框接触了的mc所要执行的事件;

  hits = my_mc[i];

  hits._alpha = 40;

  //为了可视化效果,我将被选种的任何mc的透明度改变了。

  }

  }

  }

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: 添加文本框

下一篇: FlashMX文字工具和INPUT文本