A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Testing buttons to get to other scenes. 1021 error.

  1. #1
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13

    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

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    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{


    ~calmchess~

  3. #3
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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.

  4. #4
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    no the function that is attached to the buttons via the eventlistener needs a diffrent name.......
    ~calmchess~

  5. #5
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    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
    ~calmchess~

  7. #7
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    I put a 0 and a 1 after the functions. It didn't work.
    :S
    I'm still a little confused..

  8. #8
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    show me the code for the functions i can't determine your problem without it.
    ~calmchess~

  9. #9
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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.

  10. #10
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    change function MouseDownHandler to MouseDownHandler0 and MouseDownHandler1 also change the eventlistners to MouseDownHandler0 and MouseDownHandler1
    ~calmchess~

  11. #11
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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()"

  12. #12
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    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"); 
    ~calmchess~

  13. #13
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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.

  14. #14
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    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");
    ~calmchess~

  15. #15
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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.

  16. #16
    Junior Member
    Join Date
    May 2010
    Location
    Californiaa.
    Posts
    13
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center