Flash / AS3: Type was not found or was not a compile-time constant

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; } 
+4
source share
1 answer

I just found a solution!

curtismorley.com/2007/06/20/flash-cs3-flex-2-as3-error-1046

In the first paragraph, he mentions objects in your scene, and your library cannot have the same name. In my case, I had an asset called "toc" in the library, and referenced "toc" through the instance name. By changing this, the problem is resolved. I searched a day and a half for this stupid mistake.

+11
source

Source: https://habr.com/ru/post/1487292/


All Articles