A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Problem with buttons and MC

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    Problem with buttons and MC

    Hi, I'm very new in flash so I have a little question.

    I'm doing a project for school and the setting is like this.

    I am making a interactive flash movie. The root have to following.

    3 buttons a bg an action frame with the stop(); command and a movieclip that plays a character flying around the screen. (this movieclip have 155 frames the character does not show at frame 70 and frame 155)

    Now when the user click a button with gotoAndPlay it goes to the frame I need but the movieclip of the character get interrupted by this action making it to disappear and the go to the next frame.

    I don't want that. What I want is when the user click the button the action is delayed until the character in the moviclip disappears from view (frame 70 or 155 in my secondary movie clip) and only then execute the action.

    The thing is that the character walks in and press the button when the button is pressed... that's why I need don't need the character on screen by the time the user click a button.

    Can someone help me?

    thanks!

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Well, you'll have to use some unfamiliar coding, though. On the frame where you have stop(); - after that code, type this:

    Actionscript Code:
    forward = false;

    Then, in your button actions, which I presume is something like this:

    Actionscript Code:
    on(release){
        gotoAndPlay();
    }

    and a Frame Number inside gotoAndPlay. Change gotoAndPlay() to this:

    Actionscript Code:
    _root.forward = true;

    Making your final button code look like this:

    Actionscript Code:
    on(release){
        _root.forward = true;
    }

    Then, enter your Movieclip, and go to Frame 70. Click on that Frame and open the Actions Panel, and type this:

    Actionscript Code:
    if(_root.forward == true){
        _root.gotoAndPlay(2);
    }

    and just change the Frame Number to the desired destination frame. Type the same code on Frame 155 as well.

    This may be a bit too advanced for you, but hopefully it'll do the trick
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    Talking

    Nig 13 you are a life saver... you make my day... everything is perfect.

    Thank you so much!!!

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    No problem ^^
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Junior Member
    Join Date
    Jun 2012
    Posts
    16

    Unhappy

    Hi again, ok I was testing this option and everything worked great... but when I used the same code on the other buttons... well ... no so good...

    now I have another problem that when the character is not in the stage

    if(_root.forward == true){
    _root.gotoAndPlay(2);
    }

    all the buttons go to frame 2.... but I need it for each button different frame...

    what can I do to resolve this?

    // As I explained before the root have 3 buttons, each on one triggers the same animation (the character clicking the button) but each of these animation are in different frames... so what can I do to put the code of each button and still get the same result?

    thanks again for the help

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    Button 1:
    Actionscript Code:
    on(release){
        _root.forward1 = true;
    }

    Button 2:
    Actionscript Code:
    on(release){
        _root.forward2 = true;
    }

    Button 3:
    Actionscript Code:
    on(release){
        _root.forward3 = true;
    }

    Frame 70 and Frame 155:
    Actionscript Code:
    if(_root.forward1 == true){
        // button was 1 pressed
        _root.gotoAndPlay(2);
    } else if(_root.forward2 == true){
        // button 2 was pressed
        _root.gotoAndPlay(3);
    } else if(_root.forward3 == true){
        // button 3 was pressed
        _root.gotoAndPlay(4);
    }

    Main Frame 1:
    Actionscript Code:
    stop();
    forward1 = false;
    forward2 = false;
    forward3 = false;

    Hope this works
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Junior Member
    Join Date
    Jun 2012
    Posts
    16
    hahaha you made it so easy, thanks!!! a whole internet for you sir!

  8. #8
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    No problem, glad it works
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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