ActionScript "3" Button help!!
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: ActionScript "3" Button help!!

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    1

    ActionScript "3" Button help!!

    I just switched from Action Script 2 to Action Script 3 to test a bit. But now I am sitting firmly on a really annoying problem.

    I was going to make a small game and to do so, I created a Start button and then 3 buttons to choose which level to begin on. simply made a text in frame "1" and the converted it into a button with <Instance name> START_BUTTON. in frame 1 This is the code:

    Code:
    stop();
    
    START_BUTTON.addEventListener(MouseEvent.CLICK, clickedButton);
    
    function clickedButton (event:MouseEvent)
    {
            gotoAndStop(2);
    }
    on frame "2" so I crerated 3 buttons with <Instance name> EASY_BUTTON, NORMAL_BUTTON and HARD_BUTTON. The code to this is:

    Code:
    EASY_BUTTON.addEventListener(MouseEvent.CLICK, clickedButton);
    
    function clickedButton3 (event:MouseEvent)
    {
            gotoAndStop(3);
    }
    
    NORMAL_BUTTON.addEventListener(MouseEvent.CLICK, clickedButton);
    
    function clickedButton4 (event:MouseEvent)
    {
            gotoAndStop(4);
    }
    
    HARD_BUTTON.addEventListener(MouseEvent.CLICK, clickedButton);
    
    function clickedButton5 (event:MouseEvent)
    {
            gotoAndStop(5);
    }
    when I click on START_BUTTON it takes me from frame "1" to frame "2" and thats great. BUT on frame "2" none of the three buttons is working. I can see that there are buttons when I drag the mouse over them but nothing happens when I click on em. Ofcourse I have done something on frame 3,4,5 so the problem is not that the buttons has none frame to go to.

    What do i do wrong?

    I am very happy for all the answers!!!

  2. #2
    Member
    Join Date
    Dec 2004
    Posts
    68
    In all of your event listeners you are assigning the function 'clickedButton', so each button takes you to frame 2. Change the EASY_BUTTON event listener's function to 'clickedButton3', the NORMAL_BUTTON's function to 'clickedButton4', and so on.

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

Poll by Flashkit.com