dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Controlling Movieclips with buttons

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21

    Controlling Movieclips with buttons

    Ok here is the problem. I've created 3 movie clips that fades in an image and fades out.

    Home Clip 1. fades in from 1-10 then fades out from 11-20

    About Clip 2. fades in from 20-30 then fades out from 30-40

    Contact Clip 3. fades in from 40-50 then fades out from 50-60


    I have 3 buttons that I want to control the movie clips with.

    Home button, About button and Contact button.

    How can I make one movie close and have another open after?

    For example: If HomeClip is on frame 10 and I click on the Contact button then goto frame 11 and Play and after Home Clip has closed the Contact Clip plays from 40-50.


    I want to be able to control a movieclip only if it's in a certain frame number.

    Can anyone help with that?

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    1.) you need to take your "HOME" animation and make it a movie clip
    ..do the same with your "ABOUT" frames and "CONTACT" frames...

    you will probably have to cut and paste the frames into new movie clips.

    Make sure these 3 movie clips are on the stage with the instance names of
    about_mc
    home_mc
    contact_mc
    make sure each of them has a "stop;" action on the frame in the middle on the in/out parts of the animation.

    when you get this far...post back..we'll go over step 2

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21
    Hye thanks for the response. Ok I'm reay for step 2


  4. #4
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I have attached a generic .fla for you to examine.

    basically how this works:

    you have a button (three), that does a few things:

    a.) it checks for the status of a variable "focusClip"..if empty (no value) it starts playing its matching movie (button 1 starts movie 1..etc)

    b.) if there "IS" a value for "focusClip" set..it plays "focusClip"'s "fadeOut" frameLabel

    c.) it sets the value of a variable "newClip" to be clipX ("X" being the number for each clip..if button 1..then it will say clip1..if button 2= clip2...etc)

    in your "animations" clip1, clip2 clip3....it does several things as FRAME ACTIONS:

    a.) on the middle (stop frame.. you add a frame Lable of "fadeOut"

    b.) on the same frame as above you set the variable focusClip = to that clips instance name (example: _root.focusClip = _root.clip1; )

    c.) on the last frame you have an action that starts the variable "newClip" (set above by each button press) to play. (example: _root.newClip.gotoAndPlay(2); )


    here is the .fla....if you have any questions..let me know.
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21

    Hey Whispers

    Thanks for the help. I took a look at the attachment and it seemed to be what i'm looking for. I'll be back if it doesn't work..haha.

    Thanks again

  6. #6
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21

    Hey Whisper

    I want to put the 3 buttons into a movie clip so that they can fade in after the preloader loads the movie. I put them in a movieclip called "BUTTONANIMATIONCLIP"

    The code for button 1 is this:

    on (release) {
    if (focusClip == "") {
    _root.clip1.gotoAndPlay(2);
    } else {
    _root.focusClip.gotoAndPlay("fadeOut");
    _root.newClip = clip1;
    }
    }


    How can I control Clip1 if I put the button in the movie clip "buttonanimationclip"?

  7. #7
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    Quote Originally Posted by Mister Minion
    I want to put the 3 buttons into a movie clip so that they can fade in after the preloader loads the movie. I put them in a movieclip called "BUTTONANIMATIONCLIP"

    The code for button 1 is this:

    on (release) {
    if (_root.focusClip == "") {
    _root.clip1.gotoAndPlay(2);
    } else {
    _root.focusClip.gotoAndPlay("fadeOut");
    _root.newClip = _root.clip1;
    }
    }


    How can I control Clip1 if I put the button in the movie clip "buttonanimationclip"?


    in BOLD red..

  8. #8
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21
    I tried that but it didn't work, I'll check the code again to make sure but thanks again!!

  9. #9
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I just did it twice....

  10. #10
    Junior Member
    Join Date
    Oct 2005
    Location
    I am everywhere, yet no where. If that makes any sense
    Posts
    21
    Ok it works now, I saw what I did wrong. On the last line I forgot to add "_root" to "Clip1" "Clip2" and "Clip3".

    Time to get back to work on it, thanks

  11. #11
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    thats why both were in RED and BOLDED!

    lol
    good luck..

  12. #12
    Member
    Join Date
    May 2005
    Posts
    91
    hey whispers, is there any way to keep the buttons in the downstate once you hit them? and then return to their offstate when you hit another button?

  13. #13
    Junior Member
    Join Date
    Jan 2007
    Posts
    7
    I can't figure this out for the life of me. Please help. I have tried so many things, so now I'm just going to post the .fla out of desperation.

    www.mad-avenue.com/gunar/console.fla

    sorry its so effing messy.
    Frames of interest:
    mainstage_mc
    menubg_mc
    profile_mc

    thanks man

  14. #14

  15. #15
    Junior Member
    Join Date
    Jan 2007
    Posts
    7
    Haha, ok sorry.

    Inside of there, I have the menu that pops out in the menubg_mc, I have the "profile" instance of profile_mc in the mainstage_mc on it's own layer. the focusClip="" is in there on it's own movie clip. I did that in an effort to duplicate the way your timeline worked in your example. I want to be able to transition in a different movie clip for each item on the menu. I haven't gotten so far as to create the movie clips for each, I just wanted to get it to work on the Profile link.

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