title: How to make items invisible in actionscript
body: <p>This may sound like a simple question which I'm sure has a simple solution, but basicaly... I'm making an actionscript game, and I want the player to be able to click on a book and then for a key to appear. I can get both these elements to disappear. I just can't figure out how to have the key invisible until someone clicks the book. </p>
  
  <p>Here is the code: </p>
  
  <pre><code>import flash.events.MouseEvent;
  
  book.addEventListener(MouseEvent.CLICK,getBook);
  key.addEventListener(MouseEvent.CLICK,getKey);
  //door.addEventListener(MouseEvent.CLICK,gotoBedroom);
  
  var gotBook:Boolean = false;
  var gotKey:Boolean = false;
  
  
  function getKey(evt:MouseEvent):void{
      if(gotBook==false){
          key.visible = false;
      }else{
          key.visible = true;
      }
  }
  
  if(gotBook==true){
      book.visible = false;
      key.visible = true;
      }
  
  
  function getBook(evt:MouseEvent):void{
      book.visible = false;
      key.visible = true;
  
  }
  </code></pre>