Skip to main content
Known Participant
February 19, 2009
Answered

1024 Error in AS3

  • February 19, 2009
  • 4 replies
  • 1360 views
1024: Overriding a function that is not marked for override.

OK, basically trying to move through a frame by frame animation with the first two previous and next buttons, but also allow people to jump to certain frames with other buttons.

here is the code producing the 1024 error

btnNext.addEventListener (MouseEvent.CLICK, moveNext);
function moveNext(evt:MouseEvent):void {
nextFrame();
};

btnPrev.addEventListener (MouseEvent.CLICK, movePrev);
function movePrev(evt:MouseEvent):void {
prevFrame();
};

btnPreschool.addEventListener (MouseEvent.CLICK, gotoAndStop);
function gotoAndStop(evt:MouseEvent) {
gotoAndStop("preschool");
};

stop()

I have tried everything I can think of. I am a complete n00b at this and am completely lost.
This topic has been closed for replies.
Correct answer Newsgroup_User
sholditch,

Your problem happens in these two lines:

> btnPreschool.addEventListener (MouseEvent.CLICK, gotoAndStop);
> function gotoAndStop(evt:MouseEvent) {

The reason this is a problem is because ActionScript already contains a
function (actually, a MovieClip method) called gotoAndStop(). In the lines
you just showed, you're asking Flash to forget what it already knows as
"gotoAndStop" and, instead, run a custom function of the same name.

This sort of thing is allowed if the function in question is slated for
replacement in the original class file (here, the MovieClip class). By
replacement, I mean that the function is question can optionally be allowed
to be replaced, or overridden, at runtime.

Because the gotoAndStop() method is *not* marked for override, you get
the 1024 message when you attempt to override it:

> 1024: Overriding a function that is not marked for override.

So, the quickest way around this error is to come up with a different
name for your btnPreschool event handler. How about "jumpToFrame"?

btnPreschool.addEventListener (MouseEvent.CLICK, jumpToFrame);
function jumpToFrame(evt:MouseEvent):void {
gotoAndStop("preschool");
};


David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."


4 replies

Inspiring
February 20, 2009
sholditch,

> David, once again, you are my hero.

Sweet! Glad I could help.

> Your book just arrived at home and I am very much
> looking forward to delving into the AS3.0 chapter. I
> feel like if I can just get my head wrapped around the
> basics this stuff will come a lot easier to me.

It was definitely that way for me with AS2, and then again with AS3. In
fact, I suspect it's true for a lot of people. When it comes to new
territory, many find it hard to know where to begin.

Naturally, I hope you get value out of the book, but even at 650+ pages,
there's no way Tom and I could anticipate everyone's questions, so don't
hesitate to get in touch with either of us if you spot something that
doesn't make sense (contact info is in "About the Authors"). The book's
website has a Corrections page that lists typos reported by readers, so make
sure to check that out:

http://www.FoundationFlashCS3.com/
http://www.FoundationFlashCS4.com/

Plus, I've been on these forums for years, so I'm usually not too hard
to find.


David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."


sholditchAuthor
Known Participant
February 19, 2009
David, once again, you are my hero. Your book just arrived at home and I am very much looking forward to delving into the AS3.0 chapter. I feel like if I can just get my head wrapped around the basics this stuff will come a lot easier to me. Thanks again, Timeline is working fine now.
Newsgroup_UserCorrect answer
Inspiring
February 19, 2009
sholditch,

Your problem happens in these two lines:

> btnPreschool.addEventListener (MouseEvent.CLICK, gotoAndStop);
> function gotoAndStop(evt:MouseEvent) {

The reason this is a problem is because ActionScript already contains a
function (actually, a MovieClip method) called gotoAndStop(). In the lines
you just showed, you're asking Flash to forget what it already knows as
"gotoAndStop" and, instead, run a custom function of the same name.

This sort of thing is allowed if the function in question is slated for
replacement in the original class file (here, the MovieClip class). By
replacement, I mean that the function is question can optionally be allowed
to be replaced, or overridden, at runtime.

Because the gotoAndStop() method is *not* marked for override, you get
the 1024 message when you attempt to override it:

> 1024: Overriding a function that is not marked for override.

So, the quickest way around this error is to come up with a different
name for your btnPreschool event handler. How about "jumpToFrame"?

btnPreschool.addEventListener (MouseEvent.CLICK, jumpToFrame);
function jumpToFrame(evt:MouseEvent):void {
gotoAndStop("preschool");
};


David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."


Inspiring
February 19, 2009
Oh, you are not allowed to name your last function gotoAndStop as this method is already (a very fundamental) part of AS3. Just call it gotoPreschool or sth like this and it should work fine!