home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / railway-line.swf / scripts / DefineSprite_257 / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2005-09-29  |  1.8 KB  |  71 lines

  1. function do_attach_new_piece(passed_y)
  2. {
  3.    spawn_piece_counter++;
  4.    new_ID = "spawn_piece_" + spawn_piece_counter;
  5.    this.attachMovie("drag_track_MC",new_ID,spawn_piece_counter);
  6.    this[new_ID]._x = slider_x;
  7.    this[new_ID]._y = passed_y;
  8. }
  9. function do_drop_piece(passed_name, passed_type, passed_y)
  10. {
  11.    var drop_flag = true;
  12.    drop_flag = do_test_outside_grid();
  13.    if(drop_flag == true)
  14.    {
  15.       drop_flag = do_test_against_existing_track();
  16.    }
  17.    if(_root.lost_life_dialog_MC._visible == true)
  18.    {
  19.       drop_flag = false;
  20.    }
  21.    if(drop_flag == false)
  22.    {
  23.       do_return_piece_to_start(passed_name,passed_y);
  24.    }
  25.    else
  26.    {
  27.       r = 1;
  28.       while(r <= 8)
  29.       {
  30.          c = 1;
  31.          while(c <= 8)
  32.          {
  33.             if(_root.grid_MC["square" + r + c].hitTest(_root._xmouse,_root._ymouse,0))
  34.             {
  35.                seg_x = _root.grid_MC["square" + r + c]._x;
  36.                seg_y = _root.grid_MC["square" + r + c]._y;
  37.                _root.do_attach_track_segment(passed_type,seg_x,seg_y);
  38.                _root.lay_track_sound.start();
  39.                removeMovieClip(this[passed_name]);
  40.                do_attach_new_piece(passed_y);
  41.                return undefined;
  42.             }
  43.             c++;
  44.          }
  45.          r++;
  46.       }
  47.    }
  48. }
  49. function do_test_outside_grid()
  50. {
  51.    if(!_root.grid_MC.hitTest(_root._xmouse,_root._ymouse,true))
  52.    {
  53.       return false;
  54.    }
  55.    return true;
  56. }
  57. function do_test_against_existing_track()
  58. {
  59.    if(_root.track_segments_MC.hitTest(_root._xmouse,_root._ymouse,true))
  60.    {
  61.       return false;
  62.    }
  63. }
  64. function do_return_piece_to_start(passed_name, passed_y)
  65. {
  66.    stopDrag();
  67.    _root.no_drop_sound.start();
  68.    this[passed_name]._x = slider_x;
  69.    this[passed_name]._y = passed_y;
  70. }
  71.