title: Flash/AS3: Type was not found or was not a compile-time constant
body: <p>it's been several years since I've touched AS3, but have a project requiring a bit of scripting.</p>
  
  <p>I'm trying to have a Table of Contents menu slide down, then slide up, depending on a generic Open/Close button. The concept is the same as using .slideToggle() in jQuery.</p>
  
  <p>I've created a MovieClip, given it an Instance Name and have Exported it for ActionScript in my Library, but for some reason, when I try and run a method to just shift it down 325px, I keep getting this error:</p>
  
  <p>1046: Type was not found or was not a compile-time constanc: toc.</p>
  
  <p>I realize that the library is missing a reference for something, but since the MC has an Instance Name and has been exported for AS, I'm a little puzzled as to what it could be. All of my scripts are in Frame 1, and I'm not using any external classes. Any help/pointers would be greatly appreciated!! I'm also having the same issue when I try to create the Email link, towards the bottom of my code.</p>
  
  <p>Again, any help would be greatly appreciated!! Thanks!!</p>
  
  <pre><code>import flash.events.MouseEvent;
  import flash.display.MovieClip;
  import flash.display.SimpleButton;
  
  // Initial load elements
  gotoAndStop("Frame1");
  UpdateFrame();
  
  // Mouse events
  btnNextSlide.addEventListener(MouseEvent.CLICK, NextSlide);
  btnPrevSlide.addEventListener(MouseEvent.CLICK, PrevSlide);
  btnTOC.addEventListener(MouseEvent.CLICK, ShowToC);
  //btnDifferenceLink.addEventListener(MouseEvent.CLICK, Email);
  
  // Various Methods
  function NextSlide(event:MouseEvent):void
  {
  // find current slide, go to next slide
  var currentFrame = this.currentFrame;
  var nextFrame = currentFrame + 1;
  
  if (int(nextFrame) == this.totalFrames)
  {
      // stop
      gotoAndStop("Frame" + this.framesLoaded);
  }
  else
  {
      // go to next slide
      gotoAndStop("Frame" + nextFrame);
  }
  
  // go to and stop at the next frame
  UpdateFrame();
  }
  
  function PrevSlide(event:MouseEvent):void
  {
  // find current slide
  var currentFrame = this.currentFrame;
  var prevFrame = currentFrame - 1;
  
  if (int(prevFrame) == 1)
  {
      // stop
      gotoAndStop("Frame1");
  }
  else
  {
      // go to next slide
      gotoAndStop("Frame" + prevFrame);
  }
  
  // go to and stop at the next frame
  UpdateFrame();
  }
  
  function UpdateFrame():void
  {
  txtCurrentSlide.text = this.currentFrame.toString();
  }
  
  function Email():void
  {
  var email:URLRequest = new URLRequest("mailto:emailaddress");
  navigateToURL(email, "_blank");
  }
  
  function ShowToC():void
  {
  // slide Table of Contents down
  toc.y = 325;
  }
  
  function HideToC():void
  {
  // slide Table of Contents up
  toc.y = -325;
  }
  </code></pre>