home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / bumpcopter2.swf / scripts / frame_59 / DoAction.as
Encoding:
Text File  |  2006-06-13  |  4.8 KB  |  222 lines

  1. function removeAllObjects()
  2. {
  3.    for(var _loc3_ in _root)
  4.    {
  5.       var _loc2_ = _root[_loc3_];
  6.       if(typeof _loc2_ == "movieclip" && _loc2_.removable)
  7.       {
  8.          _loc2_.removeMovieClip();
  9.       }
  10.    }
  11. }
  12. function newObject(type, x, y)
  13. {
  14.    _root.level_array.push([type,Math.round(x),Math.round(y)]);
  15.    return level_array.length - 1;
  16. }
  17. function arrayToString(arr)
  18. {
  19.    var _loc3_ = "";
  20.    var _loc2_ = 0;
  21.    while(_loc2_ < arr.length)
  22.    {
  23.       var _loc1_ = arr[_loc2_];
  24.       if(_loc2_ == 0)
  25.       {
  26.          _loc3_ += _loc1_[0] + "," + _loc1_[1] + ":";
  27.       }
  28.       else if(_loc2_ == 1)
  29.       {
  30.          _loc3_ += _loc1_;
  31.       }
  32.       else
  33.       {
  34.          _loc3_ += ":" + _loc1_[0] + "," + _loc1_[1] + "," + _loc1_[2];
  35.       }
  36.       _loc2_ = _loc2_ + 1;
  37.    }
  38.    return _loc3_;
  39. }
  40. function stringToArray(str)
  41. {
  42.    var _loc3_ = [];
  43.    var _loc4_ = str.split(":");
  44.    var _loc1_ = 0;
  45.    while(_loc1_ < _loc4_.length)
  46.    {
  47.       var _loc2_ = _loc4_[_loc1_].split(",");
  48.       if(_loc1_ == 0)
  49.       {
  50.          _loc3_.push([_loc2_[0],_loc2_[1]]);
  51.       }
  52.       else if(_loc1_ == 1)
  53.       {
  54.          _loc3_.push(_loc4_[_loc1_]);
  55.       }
  56.       else
  57.       {
  58.          _loc3_.push([_loc2_[0],_loc2_[1],_loc2_[2]]);
  59.       }
  60.       _loc1_ = _loc1_ + 1;
  61.    }
  62.    return _loc3_;
  63. }
  64. function stringToLevel(str)
  65. {
  66.    var _loc4_ = stringToArray(str);
  67.    level_array = [];
  68.    removeAllObjects();
  69.    var _loc3_ = 0;
  70.    while(_loc3_ < _loc4_.length)
  71.    {
  72.       var _loc2_ = _loc4_[_loc3_];
  73.       if(_loc3_ == 0)
  74.       {
  75.          _root.copter._x = _loc2_[0];
  76.          _root.copter._y = _loc2_[1];
  77.          level_array[0] = [];
  78.          setCopterPosition(_loc2_[0],_loc2_[1]);
  79.       }
  80.       else if(_loc3_ == 1)
  81.       {
  82.          BG.gotoAndStop(_loc2_);
  83.          setBG(_loc2_);
  84.       }
  85.       else
  86.       {
  87.          attachItem(_loc2_[0],_loc2_[1],_loc2_[2]).updateData();
  88.       }
  89.       _loc3_ = _loc3_ + 1;
  90.    }
  91. }
  92. function fadeInCodeBox()
  93. {
  94.    codeBox._visible = true;
  95.    codeBox.onEnterFrame = function()
  96.    {
  97.       if(this._alpha >= 100)
  98.       {
  99.          this._alpha = 100;
  100.          Selection.setFocus(this.code);
  101.          this.onEnterFrame = null;
  102.       }
  103.       this._alpha += 10;
  104.    };
  105. }
  106. function fadeOutCodeBox()
  107. {
  108.    codeBox.onEnterFrame = function()
  109.    {
  110.       if(this._alpha <= 0)
  111.       {
  112.          this._alpha = 0;
  113.          this._visible = false;
  114.          this.onEnterFrame = null;
  115.       }
  116.       this._alpha -= 10;
  117.    };
  118. }
  119. function timeCrAdd()
  120. {
  121.    timeCr++;
  122. }
  123. MovieClip.prototype.makeDraggable = function()
  124. {
  125.    this.useHandCursor = false;
  126.    this.removable = true;
  127.    this.onPress = function()
  128.    {
  129.       if(!edit)
  130.       {
  131.          return undefined;
  132.       }
  133.       this.startDrag();
  134.    };
  135.    this.onRelease = this.onReleaseOutside = function()
  136.    {
  137.       this.stopDrag();
  138.       this.updateData();
  139.    };
  140. };
  141. items = [obs,wu,wl,wulo,wllo,flag,wSrightSmall,wSleftSmall,wSleftBig,wSrightBig,obsHOR,mine,mace,spin];
  142. itemsNum = 2;
  143. _global.attachItem = function(type, x, y)
  144. {
  145.    if(!edit)
  146.    {
  147.       return undefined;
  148.    }
  149.    var _loc4_ = items[type];
  150.    if(_loc4_ == flag)
  151.    {
  152.       flag_btn.enabled = false;
  153.    }
  154.    var _loc3_ = _loc4_.duplicateMovieClip("item" + itemsNum,_root.getNextHighestDepth(),{_x:x,_y:y});
  155.    itemsNum++;
  156.    var _loc5_ = newObject(type,x,y);
  157.    _loc3_.index = _loc5_;
  158.    _loc3_.type = type;
  159.    _loc3_.updateData = function()
  160.    {
  161.       modifyObject(this.index,this.type,this._x,this._y);
  162.    };
  163.    return _loc3_;
  164. };
  165. _global.modifyObject = function(index, type, x, y)
  166. {
  167.    _root.level_array[index][0] = type;
  168.    _root.level_array[index][1] = x;
  169.    _root.level_array[index][2] = y;
  170. };
  171. _global.setCopterPosition = function(x, y)
  172. {
  173.    _root.level_array[0][0] = Math.round(x);
  174.    _root.level_array[0][1] = Math.round(y);
  175. };
  176. _global.setBG = function(BG)
  177. {
  178.    _root.level_array[1] = BG;
  179. };
  180. codeBox._alpha = codeBox._visible = 0;
  181. level_array = [];
  182. level_array[0] = [];
  183. MovieClip.prototype.removeObject = function()
  184. {
  185.    if(this.index == undefined)
  186.    {
  187.       trace("Error: This item cannot be removed");
  188.       return undefined;
  189.    }
  190.    _root.level_array.splice(this.index,1);
  191.    this.removeMovieClip();
  192. };
  193. edit = true;
  194. depth = 1;
  195. obsNum = 1;
  196. wuNum = 1;
  197. wlNum = 1;
  198. wuloNum = 1;
  199. wlloNum = 1;
  200. wSrightSmallNum = 1;
  201. setBG("mountain");
  202. setCopterPosition(copter._x,copter._y);
  203. speedMax = 0;
  204. speedMin = 0;
  205. speedPlus = 0;
  206. addOpen = true;
  207. timeCr = 0;
  208. setInterval(timeCrAdd,1000);
  209. attachItem(5,300,300);
  210. addObj.onEnterFrame = function()
  211. {
  212.    this.swapDepths(this._parent.getNextHighestDepth());
  213. };
  214. used.onEnterFrame = function()
  215. {
  216.    this.swapDepths(this._parent.getNextHighestDepth() + 1);
  217. };
  218. info.onEnterFrame = function()
  219. {
  220.    this.swapDepths(this._parent.getNextHighestDepth() + 2);
  221. };
  222.