It has been several years since I touched on AS3, but I have a project that requires a few scripts.
I'm trying to make the Table of Contents menu slide down, then move up, depending on the general Open / Close button. The concept is the same as using .slideToggle () in jQuery.
I created MovieClip considering its instance name and exported it for ActionScript in my library, but for some reason, when I try to run the method to just shift it 325 pixels, I keep getting this error:
1046: The type was not found or was not a compile-time constant: toc.
I understand that there is no link to something in the library, but since the MC has an instance name and is exported for AS, I am a little puzzled at what it might be. All my scripts are in frame 1, and I do not use any external classes. Any help / pointers would be greatly appreciated! I also have the same problem when I try to create an email link at the bottom of my code.
Again, any help would be greatly appreciated !! Thanks!!
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; }
source share