package ui
{
   import flash.display.Bitmap;
   import flash.display.Sprite;
   import flash.display.DisplayObjectContainer;
   import flash.events.MouseEvent;
   
   public class Welcome extends Object
   {
      
      public function Welcome(start:Function, rank:Function, store:Function, help:Function, about:Function, acv:Function)
      {
         super();
         this.startArea.addChild(new Bitmap(GameUI.btnAreaSrc1));
         this.storeArea.addChild(new Bitmap(GameUI.btnAreaSrc2));
         this.helpArea.addChild(new Bitmap(GameUI.btnAreaSrc2));
         this.rankArea.addChild(new Bitmap(GameUI.btnAreaSrc2));
         this.aboutArea.addChild(new Bitmap(GameUI.btnAreaSrc2));
         this.acvArea.addChild(new Bitmap(GameUI.btnAreaSrc2));
         this.startFunc = start;
         this.rankFunc = rank;
         this.storeFunc = store;
         this.helpFunc = help;
         this.aboutFunc = about;
         this.acvFunc = acv;
      }
      
      private static var StartBmp:Class = Welcome_StartBmp;
      
      public const dpo:Bitmap = new Bitmap();
      
      private const startArea:Sprite = new Sprite();
      
      private const storeArea:Sprite = new Sprite();
      
      private const helpArea:Sprite = new Sprite();
      
      private const rankArea:Sprite = new Sprite();
      
      private const aboutArea:Sprite = new Sprite();
      
      private const acvArea:Sprite = new Sprite();
      
      private var startFunc:Function;
      
      private var rankFunc:Function;
      
      private var storeFunc:Function;
      
      private var helpFunc:Function;
      
      private var aboutFunc:Function;
      
      private var acvFunc:Function;
      
      public function showAs(dpoc:DisplayObjectContainer) : void
      {
         dpoc.addChild(this.dpo);
         this.startArea.x = 362;
         this.startArea.y = 228;
         this.startArea.alpha = 0;
         dpoc.addChild(this.startArea);
         this.rankArea.x = 525;
         this.rankArea.y = 394;
         this.rankArea.alpha = 0;
         dpoc.addChild(this.rankArea);
         this.storeArea.x = 609;
         this.storeArea.y = 394;
         this.storeArea.alpha = 0;
         dpoc.addChild(this.storeArea);
         this.helpArea.x = 698;
         this.helpArea.y = 394;
         this.helpArea.alpha = 0;
         dpoc.addChild(this.helpArea);
         this.acvArea.x = 119;
         this.acvArea.y = 394;
         this.acvArea.alpha = 0;
         dpoc.addChild(this.acvArea);
         this.aboutArea.x = 31;
         this.aboutArea.y = 394;
         this.aboutArea.alpha = 0;
         dpoc.addChild(this.aboutArea);
         this.rankArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.rankArea.addEventListener(MouseEvent.MOUSE_UP,this.rank);
         this.startArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.startArea.addEventListener(MouseEvent.MOUSE_UP,this.start);
         this.storeArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.storeArea.addEventListener(MouseEvent.MOUSE_UP,this.store);
         this.helpArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.helpArea.addEventListener(MouseEvent.MOUSE_UP,this.help);
         this.aboutArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.aboutArea.addEventListener(MouseEvent.MOUSE_UP,this.about);
         this.acvArea.addEventListener(MouseEvent.MOUSE_DOWN,this.mouseDown);
         this.acvArea.addEventListener(MouseEvent.MOUSE_UP,this.acv);
      }
      
      private function mouseDown(e:MouseEvent) : void
      {
         e.target.alpha = 0.3;
      }
      
      private function rank(e:MouseEvent) : void
      {
         this.dpo.visible = false;
         this.rankArea.alpha = 0;
         this.rankArea.visible = false;
         this.rankFunc();
      }
      
      private function start(e:MouseEvent) : void
      {
         this.dpo.visible = false;
         this.startArea.alpha = 0;
         this.startArea.visible = false;
         this.startFunc();
      }
      
      private function store(e:MouseEvent) : void
      {
         this.storeArea.alpha = 0;
         this.storeArea.visible = false;
         this.storeFunc();
      }
      
      private function help(e:MouseEvent) : void
      {
         this.helpArea.alpha = 0;
         this.helpArea.visible = false;
         this.helpFunc();
      }
      
      private function about(e:MouseEvent) : void
      {
         this.aboutArea.alpha = 0;
         this.aboutArea.visible = false;
         this.aboutFunc();
      }
      
      private function acv(e:MouseEvent) : void
      {
         this.acvArea.alpha = 0;
         this.acvArea.visible = false;
         this.acvFunc();
      }
      
      public function set visible(value:Boolean) : void
      {
         this.dpo.visible = this.startArea.visible = this.aboutArea.visible = value;
         this.rankArea.visible = this.storeArea.visible = value;
         this.acvArea.visible = this.helpArea.visible = value;
         if(value)
         {
            this.dpo.bitmapData = new StartBmp().bitmapData;
         }
         else if(this.dpo.bitmapData != null)
         {
            this.dpo.bitmapData.dispose();
         }
         
      }
   }
}
