Flash实现用鼠标调整窗口的大小

2008-04-02 10:35:00来源:互联网 阅读 ()

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


  Flash MX 2004自带的Window组件,功能并不丰富。现在,我为他加上了用鼠标调整窗口的大小的功能!!

  函数:

  
//随鼠标缩放大小函数

  //finger:指针

  //wLeast:最小宽度

  //hLeast:最小高度度

  MovieClip.prototype.MouseSetSize = function(finger:String, wLeast:Number, hLeast:Number) {

  if (wLeast == undefined) {

  wLeast = 50;

  }

  if (hLeast == undefined) {

  hLeast = 30;

  }

  var depth = this.getNextHighestDepth();//指针深度

  var mc = this;

  var drag:Boolean = false;//是否能够缩放

  var nm:Number;//当前指针序号

  var px:Number;//缩放开始时的鼠标x位置

  var py:Number;//缩放开始时的鼠标y位置

  onMouseMove = function() {

  var xm = mc._xmouse;//相对鼠标x位置

  var ym = mc._ymouse;//相对鼠标y位置

  var w = mc.__width;//组件宽

  var h = mc.__height;//组件高

  //缩放组件

  if (drag) {

  if (nm == 1) {

  if (px>=4) {

  if (xm<wLeast) {

  xm = wLeast;

  }

  mc.setSize(Math.floor(xm), h);

  } else {

  mc.setSize(w-xm, h);

  if (w-xm>=wLeast) {

  mc._x = _xmouse;

  } else {

  mc.setSize(wLeast, h);

  }

  }

  } else if (nm == 2) {

  if (py>=4) {

  if (ym<hLeast) {

  ym = hLeast;

  }

  mc.setSize(w, Math.floor(ym));

  } else {

  mc.setSize(w, h-ym);

  if (h-ym>=hLeast) {

  mc._y = _ymouse;

  } else {

  mc.setSize(w, hLeast);

  }

  }

  } else if (nm == 3) {

  if (py>=4) {

  if (ym<hLeast) {

  ym = hLeast;

  }

  mc.setSize(w-xm, Math.floor(ym));

  if (w-xm>=wLeast) {

  mc._x = _xmouse;

  } else {

  mc.setSize(wLeast, Math.floor(ym));

  }

  } else {

  if (xm<wLeast) {

  xm = wLeast;

  }

  mc.setSize(Math.floor(xm), h-ym);

  if (h-ym>=hLeast) {

  mc._y = _ymouse;

  } else {

  mc.setSize(w, hLeast);

  }

  }

  } else if (nm == 4) {

  if (py>=4) {

  if (xm<wLeast) {

  xm = wLeast;

  }

  if (ym<hLeast) {

  ym = hLeast;

  }

  mc.setSize(Math.floor(xm), Math.floor(ym));

  } else {

  mc.setSize(w-xm, h-ym);

  if (w-xm>=wLeast) {

  mc._x = _xmouse;

  } else {

  mc.setSize(wLeast, h);

  }

  if (h-ym>=hLeast) {

  mc._y = _ymouse;

  } else {

  mc.setSize(w, hLeast);

  }

  }

  }

  }

  //判断是否在范围内

  if ((xm>=0 && xm<=w && ym>=0 && ym<=h) && !(xm>=3 && xm<=w-3 && ym>=3 && ym<=h-3)) {

  if (mc.mouse == undefined) {

  Mouse.hide();

  mc.attachMovie(finger, "mouse", depth, {_x:xm, _y:ym});

  startDrag(mc.mouse, true);

  nm = 1;

  }

  if (ym>=15 && ym<=h-15) {

  if (nm != 1) {

  mc.mouse.gotoAndStop(1);

  nm = 1;

  }

  } else if (xm>=15 && xm<=w-15) {

  if (nm != 2) {

  mc.mouse.gotoAndStop(2);

  nm = 2;

  }

  } else if ((ym<=3 && xm>=w-15) || (ym>=h-3 && xm<=15)) {

  if (nm != 3) {

  mc.mouse.gotoAndStop(3);

  nm = 3;

  }

  } else if ((ym<=3 && xm<=15) || (ym>=h-3 && xm>=w-15)) {

  if (nm != 4) {

  mc.mouse.gotoAndStop(4);

  nm = 4;

  }

  }

  onMouseDown = function () {

  if (mc.mouse != undefined) {

  drag = true;

  px = xm;

  py = ym;

  }

  };

  updateAfterEvent();

  } else {

  if (mc.mouse != undefined) {

  mc.mouse.removeMovieClip();

  Mouse.show();

  }

  }

  onMouseUp = function () {

  drag = false;

  };

  };

标签:

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

上一篇: 在ListBox组件中应用HTML

下一篇: 带进度条的Loading制作