暂存AS代码

来源:互联网 发布:opencv3编程入门 网盘 编辑:程序博客网 时间:2024/04/28 16:50

小角色让看看这些AS代码,暂存:

//场景宽度
var stag_x = Stage.width;
//场景高度
var Stag_y = Stage.height;
//自定义函数
function Dat(move, bot_D, bot_K, sped_x) {
 //拖动。说明:其中的四个判断用于限制图片不得超出边框范围。
 move.onPress = function() {
  this.onEnterFrame = function() {
   //向右拖的判断
   if (this._x>=0) {
    this._x = 0;
   } else if (this._x<=(Stag_y-this._width)) {
    //向左拖的判断 
    this._x = stag_x-this._width;
   }
   if (this._y>=0) {
    //向下拖的判断 
    this._y = 0;
   } else if (this._y<=Stag_y-this._height) {
    //向上拖的判断 
    this._y = Stag_y-this._height;
   }
  };
  this.startDrag();
 };
 //停止拖动 
 move.onRelease = function() {
  this.stopDrag();
 };
 //同上 
 move.onReleaseOutside = function() {
  this.stopDrag();
 };
 //扩大按钮的代码。其中的判断用于在缩小按钮不可用时恢复其可用。
 bot_D.onPress = function() {
  if (suoxiao.enabled == false) {
   suoxiao.enabled = true;
  }
  move.onEnterFrame = function() {
   this._yscale = this._xscale += sped_x;
  };
 };
 bot_D.onRelease = function() {
  delete move.onEnterFrame;
 };
 //缩小按钮的代码,其中加的限制条件是为了在缩小时防止背景漏出。
 //当达到最小的范围时,缩小按钮不可用。
 bot_K.onPress = function() {
  move.onEnterFrame = function() {
   if (this._width<=(Stage.width+Math.abs(this._x)) || this._height<=(Stage.height+Math.abs(this._y))) {
    bot_K.enabled = false;
   } else {
    this._yscale = this._xscale -= sped_x;
   }
  };
 };
 bot_K.onRelease = function() {
  delete pic.onEnterFrame;
 };
}
Dat(pic, kuoda, suoxiao, 1, 1);

原创粉丝点击