-
Testing buttons to get to other scenes. 1021 error.
I'm testing buttons and making them navigate to different scenes for one of my teachers who wants to start building websites in one of his classes.
But anyways,
My problem is this;
"1021: Duplicate function definition.
Is it because I used the same code (but different instance names) to navigate from scene to scene?
Well, it actually didn't work, that's why I'm here, asking this.
Please help?
Last edited by raee; 05-25-2010 at 11:32 AM.
Reason: deleted some of my post
-
Senior Member
you have two functions with the same name like ths
PHP Code:
funciton mynamis0():void{
|
funciton mynamis0():void{
|
when it should be
PHP Code:
funciton mynamis0():void{
|
funciton mynamis1():void{
|
-
The buttons do have a different name though. In scene one, the button is "button" and in scene two it's "button2".
If that's waht you're saying.
-
Senior Member
no the function that is attached to the buttons via the eventlistener needs a diffrent name.......
-
Yeah, I relooked that post, makes sense. Sorry.
But what would I rename it? Just have a number after it..?
I'm sort of new at this. :S
-
Senior Member
absolutely have a number after it start with zero heck number all your variables and object names/refrences never know when you will want to use a for loop, array, or dynamically refrence variable /function names
-
I put a 0 and a 1 after the functions. It didn't work.
:S
I'm still a little confused..
-
Senior Member
show me the code for the functions i can't determine your problem without it.
-
This is for the first button in scene one.
Code:
button_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(1, "Scene2");
}
This is the second, scene two.
Code:
button2_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay(1, "Scene1");
}
Yeah, I know that isn't right at all, but I can't find any other code that works either.
-
Senior Member
change function MouseDownHandler to MouseDownHandler0 and MouseDownHandler1 also change the eventlistners to MouseDownHandler0 and MouseDownHandler1
-
It gave me an error...
Unless I didn't put the numbers in the right spot?
"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at test_fla::MainTimeline/frame25()
at flash.display::MovieClip/gotoAndPlay()
at test_fla::MainTimeline/mouseDownHandler0()"
-
Senior Member
are your buttons avaiable and have the right instance names? because you have the functions straightened out now but something else is wrong its either the buttons names or this...........did you try to put both the frame number and scene label int the gotoAndPlay ?I don't think you need both.
PHP Code:
gotoAndPlay("Scene1");
-
This is my code for scene 1
Code:
button_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler0);function mouseDownHandler0(event:MouseEvent):void {
gotoAndPlay(1, "Scene2");
}
this is scene two
Code:
button2_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);function mouseDownHandler1(event:MouseEvent):void {
gotoAndPlay(1, "Scene1");
}
I don't know what's wrong S:
Last edited by raee; 06-01-2010 at 11:00 AM.
Reason: didn't add code tags.
-
Senior Member
your button instances aren't avaiable....make sure your buttons are on the frame where they are being called and try to trace them trace(button_btn); report back here on your findings keep trying untill you are sure your buttons are available and the eventlisteners are being called and can trace a message trace("test message");
-
I changed the instance names to blue and green btn and made sure they were all right in the code but I still get the error.
This is what it says.
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at test_fla::MainTimeline/frame25()
at flash.display::MovieClip/gotoAndPlay()
at test_fla::MainTimeline/mouseDownHandler0()
But whatever. I give up.
Thank you fro trying.
-
Ok no nevermind, I don't give up. This will bother me.
So I changed the names back to enter and enter2 _btn & my friend thought that the button needed to be on all the scenes to work? I tried that, it didn't work.
I think it'd be way easier if someone looked at the file and code. Buuut, I can't figure out how to do that..?
Okayy, I can get to scene two, but then the error message pops up, and I try to click the button on scene two, it lets me click it, but it doesn't do crap Dx
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|