it's been several years since I've touched AS3, but have a project requiring a bit of scripting.
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.
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:
1046: Type was not found or was not a compile-time constanc: toc.
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.
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;
}
I have just found the solution!
curtismorley.com/2007/06/20/flash-cs3-flex-2-as3-error-1046
In his first paragraph, he mentions objects on your stage and in your library cannot have the same name. In my case, I had an asset called "toc" in the library, and was referencing "toc" via Instance Name. By changing this, the problem has been solved. I've been searching for a day and a half on this stupid error..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With