home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / HexiomConnect.swf / scripts / Level.as < prev    next >
Encoding:
Text File  |  2008-08-29  |  21.2 KB  |  700 lines

  1. package
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.DisplayObjectContainer;
  5.    import flash.display.SimpleButton;
  6.    import flash.display.Sprite;
  7.    import flash.events.Event;
  8.    import flash.events.MouseEvent;
  9.    import flash.events.TimerEvent;
  10.    import flash.geom.Point;
  11.    import flash.system.System;
  12.    import flash.text.TextField;
  13.    import flash.utils.Timer;
  14.    
  15.    public class Level extends Sprite
  16.    {
  17.       
  18.       protected static var InterfaceGfx:Class = Level_InterfaceGfx;
  19.       
  20.       protected static var SaveDialog:Class = Level_SaveDialog;
  21.       
  22.       public static const CUSTOM:int = -1;
  23.       
  24.       protected static var Clocking:Class = Level_Clocking;
  25.       
  26.       protected static var Gap:Class = Level_Gap;
  27.       
  28.       public static const ADVANCED_RANDOM:int = -3;
  29.       
  30.       public static const BASIC_RANDOM:int = -2;
  31.       
  32.       protected static var VictoryScreen:Class = Level_VictoryScreen;
  33.        
  34.       
  35.       protected var tileGhost:Sprite;
  36.       
  37.       public var tiles:Array;
  38.       
  39.       protected var saveButton:SimpleButton;
  40.       
  41.       private var saveDialog:Sprite;
  42.       
  43.       protected var timeLabel:TextField;
  44.       
  45.       private var victoryScreen:Sprite;
  46.       
  47.       private var _time:Array;
  48.       
  49.       public var slots:Array;
  50.       
  51.       private var timer:Timer;
  52.       
  53.       protected var currentTile:Tile;
  54.       
  55.       protected var levelLabel:TextField;
  56.       
  57.       private var victoryShowing:Boolean = false;
  58.       
  59.       protected var gap:Sprite;
  60.       
  61.       private var saveOutput:TextField;
  62.       
  63.       protected var resetButton:SimpleButton;
  64.       
  65.       private var victoryTimer:Timer;
  66.       
  67.       public var board:Board;
  68.       
  69.       private var levelNumber:int;
  70.       
  71.       protected var backButton:SimpleButton;
  72.       
  73.       public function Level(param1:Board = null, param2:int = -1, param3:Boolean = false, param4:Boolean = true)
  74.       {
  75.          _time = new Array(3);
  76.          super();
  77.          time = 0;
  78.          tileGhost = Tile.getTileGhost();
  79.          gap = new Gap();
  80.          if(param1)
  81.          {
  82.             addBoard(param1);
  83.          }
  84.          else
  85.          {
  86.             addBoard(new Board(3));
  87.          }
  88.          board.addEventListener(HexEvent.GROWN,startTimer,false,0,true);
  89.          board.grow();
  90.          timer = new Timer(1000,0);
  91.          victoryTimer = new Timer(500,1);
  92.          victoryTimer.addEventListener(TimerEvent.TIMER,showVictoryScreenTime,false,0,true);
  93.          this.levelNumber = param2;
  94.          addInterface(param3,param4);
  95.          addEventListener(Event.ADDED_TO_STAGE,addedToStage,false,0,true);
  96.          addEventListener(Event.REMOVED_FROM_STAGE,removedFromStage,false,0,true);
  97.       }
  98.       
  99.       protected function resetClick(param1:MouseEvent) : void
  100.       {
  101.          var _loc2_:Tile = null;
  102.          victoryShowing = false;
  103.          hideVictoryScreen();
  104.          SoundBar.playSound(SoundBar.RESET_LEVEL_SOUND,0);
  105.          reset();
  106.          for each(_loc2_ in tiles)
  107.          {
  108.             _loc2_.flash();
  109.          }
  110.       }
  111.       
  112.       protected function startTimer(param1:HexEvent) : void
  113.       {
  114.          timer.addEventListener(TimerEvent.TIMER,secondTick,false,0,true);
  115.       }
  116.       
  117.       protected function victoryOver(param1:MouseEvent) : void
  118.       {
  119.          if(victoryShowing)
  120.          {
  121.             showVictoryScreen();
  122.          }
  123.       }
  124.       
  125.       protected function continueToMenu(param1:HexEvent) : void
  126.       {
  127.          var _loc2_:int = levelNumber;
  128.          if(levelNumber >= 1)
  129.          {
  130.             _loc2_++;
  131.          }
  132.          dispatchEvent(new HexEvent(HexEvent.NEXT_LEVEL,false,false,board,_loc2_));
  133.       }
  134.       
  135.       protected function saveClick(param1:MouseEvent) : void
  136.       {
  137.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  138.          stage.focus = saveOutput;
  139.          saveOutput.text = board.saveToText();
  140.          saveOutput.scrollH = 0;
  141.          saveOutput.setSelection(0,saveOutput.text.length);
  142.          addChild(saveDialog);
  143.       }
  144.       
  145.       protected function victory() : void
  146.       {
  147.          var _loc1_:Tile = null;
  148.          SoundBar.playSound(SoundBar.VICTORY_SOUND,0);
  149.          for each(_loc1_ in tiles)
  150.          {
  151.             _loc1_.flash();
  152.          }
  153.          victoryTimer.reset();
  154.          victoryTimer.start();
  155.          Game.completeLevel(levelNumber,board.size,time);
  156.       }
  157.       
  158.       protected function overSlot() : Slot
  159.       {
  160.          var _loc2_:DisplayObject = null;
  161.          var _loc3_:DisplayObjectContainer = null;
  162.          var _loc4_:Slot = null;
  163.          var _loc1_:Array = stage.getObjectsUnderPoint(new Point(stage.mouseX,stage.mouseY));
  164.          if(_loc1_.length)
  165.          {
  166.             for each(_loc2_ in _loc1_)
  167.             {
  168.                _loc3_ = _loc2_.parent;
  169.                while(_loc3_ != stage)
  170.                {
  171.                   if(_loc4_ = _loc3_ as Slot)
  172.                   {
  173.                      return _loc4_;
  174.                   }
  175.                   _loc3_ = _loc3_.parent;
  176.                }
  177.             }
  178.          }
  179.          return null;
  180.       }
  181.       
  182.       protected function showVictoryScreenTime(param1:TimerEvent) : void
  183.       {
  184.          var _loc2_:Sprite = null;
  185.          var _loc3_:DisplayObject = null;
  186.          if(Game.checkClocking())
  187.          {
  188.             _loc2_ = new Clocking();
  189.             _loc3_ = victoryScreen.getChildAt(victoryScreen.numChildren - 1);
  190.             _loc3_.y -= 30;
  191.             _loc2_.addChild(_loc3_);
  192.             _loc3_ = victoryScreen.getChildAt(victoryScreen.numChildren - 1);
  193.             _loc3_.y -= 30;
  194.             _loc2_.addChild(_loc3_);
  195.             victoryScreen = _loc2_;
  196.          }
  197.          victoryShowing = true;
  198.          victoryScreen.alpha = 0;
  199.          showVictoryScreen();
  200.       }
  201.       
  202.       protected function saveCopyClick(param1:MouseEvent) : void
  203.       {
  204.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  205.          System.setClipboard(saveOutput.text);
  206.       }
  207.       
  208.       protected function addInterface(param1:Boolean, param2:Boolean) : void
  209.       {
  210.          var _loc4_:TextButton = null;
  211.          var _loc3_:DisplayObjectContainer = new InterfaceGfx();
  212.          resetButton = _loc3_.getChildByName("resetButton") as SimpleButton;
  213.          saveButton = _loc3_.getChildByName("saveButton") as SimpleButton;
  214.          backButton = _loc3_.getChildByName("backButton") as SimpleButton;
  215.          levelLabel = _loc3_.getChildByName("levelLabel") as TextField;
  216.          levelLabel.mouseEnabled = false;
  217.          timeLabel = _loc3_.getChildByName("timeLabel") as TextField;
  218.          timeLabel.mouseEnabled = false;
  219.          if(param2)
  220.          {
  221.             addChild(levelLabel);
  222.             if(levelNumber == CUSTOM)
  223.             {
  224.                levelLabel.text = "Custom";
  225.             }
  226.             else if(levelNumber == BASIC_RANDOM || levelNumber == ADVANCED_RANDOM)
  227.             {
  228.                levelLabel.text = "Random";
  229.             }
  230.             else
  231.             {
  232.                levelLabel.text = "Level " + levelNumber;
  233.             }
  234.             addChild(timeLabel);
  235.             timer.start();
  236.             updateTime();
  237.          }
  238.          saveDialog = new SaveDialog();
  239.          (_loc4_ = new TextButton(TextButton.LONG,"Copy")).x = 140;
  240.          _loc4_.y = 240;
  241.          _loc4_.addEventListener(MouseEvent.CLICK,saveCopyClick,false,0,true);
  242.          saveDialog.addChild(_loc4_);
  243.          (_loc4_ = new TextButton(TextButton.LONG,"Ok")).x = 260;
  244.          _loc4_.y = 240;
  245.          _loc4_.addEventListener(MouseEvent.CLICK,saveOkClick,false,0,true);
  246.          saveDialog.addChild(_loc4_);
  247.          saveOutput = saveDialog.getChildByName("output") as TextField;
  248.          if(param1)
  249.          {
  250.             addChild(saveButton);
  251.             saveButton.addEventListener(MouseEvent.CLICK,saveClick,false,0,true);
  252.          }
  253.          addChild(resetButton);
  254.          resetButton.addEventListener(MouseEvent.CLICK,resetClick,false,0,true);
  255.          addChild(backButton);
  256.          backButton.addEventListener(MouseEvent.CLICK,menuClick,false,0,true);
  257.          victoryScreen = new VictoryScreen();
  258.          victoryScreen.addEventListener(MouseEvent.ROLL_OVER,victoryOver,false,0,true);
  259.          victoryScreen.addEventListener(MouseEvent.ROLL_OUT,victoryOut,false,0,true);
  260.          (_loc4_ = new TextButton(TextButton.LONG,"Continue")).x = 200;
  261.          _loc4_.y = 200;
  262.          _loc4_.addEventListener(MouseEvent.CLICK,continueClick,false,0,true);
  263.          victoryScreen.addChild(_loc4_);
  264.          (_loc4_ = new TextButton(TextButton.LONG,"Replay")).x = 200;
  265.          _loc4_.y = 230;
  266.          _loc4_.addEventListener(MouseEvent.CLICK,resetClick,false,0,true);
  267.          victoryScreen.addChild(_loc4_);
  268.          (_loc4_ = new TextButton(TextButton.LONG,"Menu")).x = 200;
  269.          _loc4_.y = 260;
  270.          _loc4_.addEventListener(MouseEvent.CLICK,menuClick,false,0,true);
  271.          victoryScreen.addChild(_loc4_);
  272.          (_loc4_ = new TextButton(TextButton.LONG,"More Games")).x = 200;
  273.          _loc4_.y = 290;
  274.          _loc4_.addEventListener(MouseEvent.CLICK,moreGamesClick,false,0,true);
  275.          victoryScreen.addChild(_loc4_);
  276.       }
  277.       
  278.       private function set time(param1:int) : void
  279.       {
  280.          _time[0] = param1 * 3 - 1;
  281.          _time[1] = param1 * 7 - 2;
  282.          _time[2] = param1 * -5 - 1;
  283.       }
  284.       
  285.       protected function disableMouse() : void
  286.       {
  287.          var _loc1_:Tile = null;
  288.          for each(_loc1_ in tiles)
  289.          {
  290.             _loc1_.removeEventListener(MouseEvent.MOUSE_DOWN,tileDown);
  291.          }
  292.       }
  293.       
  294.       protected function tileMove(param1:MouseEvent) : void
  295.       {
  296.          if(!currentTile)
  297.          {
  298.             return;
  299.          }
  300.          currentTile.x = board.mouseX;
  301.          currentTile.y = board.mouseY;
  302.       }
  303.       
  304.       protected function continueClick(param1:MouseEvent) : void
  305.       {
  306.          victoryShowing = false;
  307.          hideVictoryScreen();
  308.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  309.          board.addEventListener(HexEvent.SHRUNK,continueToMenu,false,0,true);
  310.          board.shrink();
  311.       }
  312.       
  313.       protected function overTile() : Tile
  314.       {
  315.          var _loc2_:DisplayObject = null;
  316.          var _loc3_:DisplayObjectContainer = null;
  317.          var _loc4_:Tile = null;
  318.          var _loc1_:Array = stage.getObjectsUnderPoint(new Point(stage.mouseX,stage.mouseY));
  319.          if(_loc1_.length)
  320.          {
  321.             for each(_loc2_ in _loc1_)
  322.             {
  323.                _loc3_ = _loc2_.parent;
  324.                while(_loc3_ != stage)
  325.                {
  326.                   if((Boolean(_loc4_ = _loc3_ as Tile)) && _loc4_ != currentTile)
  327.                   {
  328.                      return _loc4_;
  329.                   }
  330.                   _loc3_ = _loc3_.parent;
  331.                }
  332.             }
  333.          }
  334.          return null;
  335.       }
  336.       
  337.       protected function addedToStage(param1:Event) : void
  338.       {
  339.          addEventListener(Event.ENTER_FRAME,update,false,0,true);
  340.          enableMouse();
  341.       }
  342.       
  343.       private function showVictoryScreen() : void
  344.       {
  345.          addChild(victoryScreen);
  346.          removeEventListener(Event.ENTER_FRAME,fadeOutVictoryStep);
  347.          addEventListener(Event.ENTER_FRAME,fadeInVictoryStep,false,0,true);
  348.       }
  349.       
  350.       protected function hideVictoryScreen() : void
  351.       {
  352.          removeEventListener(Event.ENTER_FRAME,fadeInVictoryStep);
  353.          addEventListener(Event.ENTER_FRAME,fadeOutVictoryStep,false,0,true);
  354.       }
  355.       
  356.       protected function secondTick(param1:TimerEvent) : void
  357.       {
  358.          ++time;
  359.          updateTime();
  360.       }
  361.       
  362.       protected function checkWin() : void
  363.       {
  364.          var _loc2_:Tile = null;
  365.          var _loc3_:Slot = null;
  366.          var _loc1_:Boolean = true;
  367.          for each(_loc2_ in tiles)
  368.          {
  369.             _loc3_ = _loc2_.slot;
  370.             if(Boolean(_loc2_.n) && (!_loc3_.n || _loc2_.n != _loc3_.n.tile.s))
  371.             {
  372.                _loc1_ = false;
  373.             }
  374.             if(Boolean(_loc2_.ne) && (!_loc3_.ne || _loc2_.ne != _loc3_.ne.tile.sw))
  375.             {
  376.                _loc1_ = false;
  377.             }
  378.             if(Boolean(_loc2_.se) && (!_loc3_.se || _loc2_.se != _loc3_.se.tile.nw))
  379.             {
  380.                _loc1_ = false;
  381.             }
  382.             if(Boolean(_loc2_.s) && (!_loc3_.s || _loc2_.s != _loc3_.s.tile.n))
  383.             {
  384.                _loc1_ = false;
  385.             }
  386.             if(Boolean(_loc2_.sw) && (!_loc3_.sw || _loc2_.sw != _loc3_.sw.tile.ne))
  387.             {
  388.                _loc1_ = false;
  389.             }
  390.             if(Boolean(_loc2_.nw) && (!_loc3_.nw || _loc2_.nw != _loc3_.nw.tile.se))
  391.             {
  392.                _loc1_ = false;
  393.             }
  394.             if(!_loc1_)
  395.             {
  396.                break;
  397.             }
  398.          }
  399.          if(_loc1_)
  400.          {
  401.             timer.stop();
  402.             victory();
  403.          }
  404.       }
  405.       
  406.       protected function updateTime() : void
  407.       {
  408.          if(Game.cheatHasBeenFound)
  409.          {
  410.             timeLabel.text = "Cheat Detected";
  411.             timeLabel.textColor = 11141120;
  412.             return;
  413.          }
  414.          var _loc1_:int = time;
  415.          var _loc2_:* = "";
  416.          var _loc3_:* = "";
  417.          var _loc4_:String = "";
  418.          var _loc5_:* = _loc1_ >= 3600;
  419.          var _loc6_:* = _loc1_ >= 60;
  420.          if(_loc5_)
  421.          {
  422.             _loc2_ = int(_loc1_ / 3600) + ":";
  423.          }
  424.          _loc1_ %= 3600;
  425.          if(_loc5_)
  426.          {
  427.             _loc3_ += int(_loc1_ / 60);
  428.             while(_loc3_.length < 2)
  429.             {
  430.                _loc3_ = "0" + _loc3_;
  431.             }
  432.             _loc3_ += ":";
  433.          }
  434.          else
  435.          {
  436.             _loc3_ = int(_loc1_ / 60) + ":";
  437.          }
  438.          _loc1_ %= 60;
  439.          _loc4_ += _loc1_;
  440.          while(_loc4_.length < 2)
  441.          {
  442.             _loc4_ = "0" + _loc4_;
  443.          }
  444.          timeLabel.text = _loc2_ + _loc3_ + _loc4_;
  445.       }
  446.       
  447.       protected function removeBoard() : void
  448.       {
  449.          var _loc1_:Tile = null;
  450.          if(!board)
  451.          {
  452.             return;
  453.          }
  454.          for each(_loc1_ in tiles)
  455.          {
  456.             _loc1_.removeEventListener(MouseEvent.MOUSE_DOWN,tileDown);
  457.          }
  458.          slots = null;
  459.          tiles = null;
  460.          if(board.parent == this)
  461.          {
  462.             removeChild(board);
  463.          }
  464.          board = null;
  465.       }
  466.       
  467.       private function get time() : int
  468.       {
  469.          var _loc1_:int = (_time[0] + 1) / 3;
  470.          if((_time[1] + 2) / 7 != _loc1_)
  471.          {
  472.             Game.cheatFound();
  473.          }
  474.          if((_time[2] + 1) / -5 != _loc1_)
  475.          {
  476.             Game.cheatFound();
  477.          }
  478.          return _loc1_;
  479.       }
  480.       
  481.       protected function reset() : void
  482.       {
  483.          var _loc1_:Tile = null;
  484.          for each(_loc1_ in tiles)
  485.          {
  486.             if(_loc1_.confirmed)
  487.             {
  488.                _loc1_.unconfirm();
  489.             }
  490.          }
  491.          board.startPositions();
  492.       }
  493.       
  494.       protected function returnToMenu(param1:HexEvent) : void
  495.       {
  496.          dispatchEvent(new HexEvent(HexEvent.MENU));
  497.       }
  498.       
  499.       protected function addBoard(param1:Board) : void
  500.       {
  501.          var _loc2_:Tile = null;
  502.          board = param1;
  503.          slots = board.slots;
  504.          tiles = board.tiles;
  505.          addChild(board);
  506.          board.x = 200;
  507.          board.y = 200;
  508.          board.scaleX = board.scaleY = 1;
  509.          board.setScale(Math.min(0.65,350 / board.width,350 / board.height));
  510.          board.addChild(tileGhost);
  511.          for each(_loc2_ in tiles)
  512.          {
  513.             _loc2_.checkNeighbours();
  514.          }
  515.       }
  516.       
  517.       protected function victoryOut(param1:MouseEvent) : void
  518.       {
  519.          if(victoryShowing)
  520.          {
  521.             hideVictoryScreen();
  522.          }
  523.       }
  524.       
  525.       protected function saveOkClick(param1:MouseEvent) : void
  526.       {
  527.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  528.          if(saveDialog.parent == this)
  529.          {
  530.             removeChild(saveDialog);
  531.          }
  532.       }
  533.       
  534.       protected function enableMouse() : void
  535.       {
  536.          var _loc1_:Tile = null;
  537.          for each(_loc1_ in tiles)
  538.          {
  539.             _loc1_.addEventListener(MouseEvent.MOUSE_DOWN,tileDown,false,0,true);
  540.          }
  541.       }
  542.       
  543.       public function update(param1:Event) : void
  544.       {
  545.          if(!currentTile)
  546.          {
  547.             tileGhost.visible = false;
  548.             return;
  549.          }
  550.          var _loc2_:Slot = overSlot();
  551.          var _loc3_:Tile = null;
  552.          if(_loc2_)
  553.          {
  554.             _loc3_ = _loc2_.tile;
  555.          }
  556.          if(Boolean(_loc3_) && !_loc3_.locked)
  557.          {
  558.             tileGhost.x = _loc3_.x;
  559.             tileGhost.y = _loc3_.y;
  560.             tileGhost.visible = true;
  561.          }
  562.          else
  563.          {
  564.             tileGhost.visible = false;
  565.          }
  566.       }
  567.       
  568.       protected function fadeOutVictoryStep(param1:Event) : void
  569.       {
  570.          victoryScreen.alpha = Math.max(0,victoryScreen.alpha - 0.1);
  571.          if(victoryScreen.alpha == 0)
  572.          {
  573.             removeEventListener(Event.ENTER_FRAME,fadeOutVictoryStep);
  574.             if(victoryScreen.parent == this && !victoryShowing)
  575.             {
  576.                removeChild(victoryScreen);
  577.             }
  578.          }
  579.       }
  580.       
  581.       protected function menuClick(param1:MouseEvent) : void
  582.       {
  583.          victoryShowing = false;
  584.          hideVictoryScreen();
  585.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  586.          board.addEventListener(HexEvent.SHRUNK,returnToMenu,false,0,true);
  587.          board.shrink();
  588.       }
  589.       
  590.       protected function swapSlots(param1:Slot, param2:Slot) : void
  591.       {
  592.          param1.swapTiles(param2);
  593.          param1.tile.flash();
  594.          param2.tile.flash();
  595.          if(param1.tile.confirmed)
  596.          {
  597.             param1.tile.unconfirm();
  598.          }
  599.          if(param2.tile.confirmed)
  600.          {
  601.             param2.tile.unconfirm();
  602.          }
  603.       }
  604.       
  605.       protected function removedFromStage(param1:Event) : void
  606.       {
  607.          removeEventListener(Event.ENTER_FRAME,update);
  608.          disableMouse();
  609.       }
  610.       
  611.       protected function tileDown(param1:MouseEvent) : void
  612.       {
  613.          var _loc2_:Tile = param1.currentTarget as Tile;
  614.          if(!_loc2_ || _loc2_.locked)
  615.          {
  616.             return;
  617.          }
  618.          if(param1.shiftKey)
  619.          {
  620.             SoundBar.playSound(SoundBar.LOCK_SOUND,mouseX / Game.MIDX - 1);
  621.             if(_loc2_.confirmed)
  622.             {
  623.                _loc2_.unconfirm();
  624.             }
  625.             else
  626.             {
  627.                _loc2_.confirm();
  628.             }
  629.             return;
  630.          }
  631.          SoundBar.playSound(SoundBar.PICKUP_SOUND,mouseX / Game.MIDX - 1);
  632.          if(_loc2_.confirmed)
  633.          {
  634.             _loc2_.unconfirm();
  635.          }
  636.          currentTile = _loc2_;
  637.          currentTile.x = board.mouseX;
  638.          currentTile.y = board.mouseY;
  639.          currentTile.alpha = 0.75;
  640.          _loc2_.parent.setChildIndex(currentTile,_loc2_.parent.numChildren - 1);
  641.          stage.addEventListener(MouseEvent.MOUSE_MOVE,tileMove,false,0,true);
  642.          stage.addEventListener(MouseEvent.MOUSE_UP,tileUp,false,0,true);
  643.          _loc2_.slot.addChild(gap);
  644.       }
  645.       
  646.       protected function tileUp(param1:MouseEvent) : void
  647.       {
  648.          if(!currentTile)
  649.          {
  650.             return;
  651.          }
  652.          if(gap.parent)
  653.          {
  654.             gap.parent.removeChild(gap);
  655.          }
  656.          var _loc2_:Slot = overSlot();
  657.          var _loc3_:Tile = null;
  658.          if(_loc2_)
  659.          {
  660.             _loc3_ = _loc2_.tile;
  661.          }
  662.          if(_loc3_ == currentTile)
  663.          {
  664.             SoundBar.playSound(SoundBar.DROP_SOUND,mouseX / Game.MIDX - 1);
  665.             currentTile.snapToSlot();
  666.          }
  667.          else if(Boolean(_loc3_) && !_loc3_.locked)
  668.          {
  669.             SoundBar.playSound(SoundBar.DROP_SOUND,mouseX / Game.MIDX - 1);
  670.             swapSlots(currentTile.slot,_loc3_.slot);
  671.             checkWin();
  672.          }
  673.          else
  674.          {
  675.             SoundBar.playSound(SoundBar.RETURN_SOUND,mouseX / Game.MIDX - 1);
  676.             currentTile.snapToSlot();
  677.          }
  678.          currentTile.alpha = 1;
  679.          stage.removeEventListener(MouseEvent.MOUSE_MOVE,tileMove);
  680.          stage.removeEventListener(MouseEvent.MOUSE_UP,tileUp);
  681.          currentTile = null;
  682.       }
  683.       
  684.       protected function moreGamesClick(param1:MouseEvent) : void
  685.       {
  686.          SoundBar.playSound(SoundBar.BUTTON_CLICK_SOUND,mouseX / Game.MIDX - 1);
  687.          Links.sponsorLink();
  688.       }
  689.       
  690.       protected function fadeInVictoryStep(param1:Event) : void
  691.       {
  692.          victoryScreen.alpha = Math.min(1,victoryScreen.alpha + 0.1);
  693.          if(victoryScreen.alpha == 1)
  694.          {
  695.             removeEventListener(Event.ENTER_FRAME,fadeInVictoryStep);
  696.          }
  697.       }
  698.    }
  699. }
  700.