A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: grouped buttons

  1. #1
    Junior Member
    Join Date
    May 2002
    Posts
    19

    grouped buttons

    I have a set of buttons in a movie clip. The movie clip is in Scene 1 and the buttons lead to different areas in scene 2. The reason that they are grouped is because they move left and right when arrow keys are clicked. but the thing is when the buttons are grouped they do not go to their desired paces. this is the syntax that I have on the buttons:
    LEFT BUT
    on (release) {
    setProperty ("/line", _x, Number(getproperty("/line", _x))-18);
    x_value = getproperty("/line", _x);
    y_value = getproperty("/line", _y);
    the MC instance is called line.
    Can someone please help me out and tell me how to get the buttons working. thank you

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    The buttons won't work when you put them in a MovieClip because you're still referring to the line MC as "/line". Since the buttons are no longer on the main timeline (they're now an extra level down inside the MC) this is incorrect.

    To reference the main timeline from any other timelime in a movie, you can use _root.mcname

    This code should do what you want it to do:

    on(release){
    _root.line._x -= 18;
    x_value = _root.line._x;
    y_value = _root.line._y;
    }

    Because I've used _root you can use it on any button no matter where it is in the movie.


    Hope this helps.

  3. #3
    Junior Member
    Join Date
    May 2002
    Posts
    19
    I'm still not fully getting it! Where do I put this code? I've tried it on the arrow buttons but its not working. Can you explain what the code is doing? Sorry, thanx

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    The code should go on the "left" button that you mentioned.

    Here's a commented version of the code:

    on(release){

    //moves the mc on the main timeline
    // with the instance name of "line"
    //18 pixels to the left of where it is
    //at the time the button is clicked
    _root.line._x -= 18;

    //sets the variable "x_value" to the
    //new x postion of the "line" mc
    x_value = _root.line._x;

    //sets the variable "y_value" to the
    //new y postion of the "line" mc
    y_value = _root.line._y;
    }

    You haven't mentioned what the variables "x_value" and "y_value" are used for (they're not needed to move the line mc). If you need these variables to be accessed from the main timeline (_root) then change the code slightly as in this version:

    on(release){
    _root.line._x -= 18;
    _root.x_value = _root.line._x;
    _root.y_value = _root.line._y;
    }

    You can then call these variables from anywhere in the movie by using:

    _root.x_value

    and

    _root.y_value


    Any help?

  5. #5
    Junior Member
    Join Date
    May 2002
    Posts
    19
    you are helping, I'm just a bit stupid! So I put that code on the arrow button, but what do I put on the actual buttons in the movie clip, I must have to metion the root again, cos at the moment I've just got on relesase goToAndPlay!
    Sorry I'm not getting this!

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    Don't worry, we'll get there...

    I think there's a problem in that you haven't fully explained what it is you're trying to do. If you can post a more indepth decription, I'm sure we can get the thing going.

    Would I be correct in thinking that you have an arrow which you're trying to move around the stage by clicking buttons?

    And that these buttons are in a movie clip which is on the main timeline (_root)?


  7. #7
    Junior Member
    Join Date
    May 2002
    Posts
    19
    This is why we are confused, I am obviously crap at explaining!!!
    Ok I have one MC that is made up of a lot of buttons (it is a historical timeline). These buttons each lead to a different date on the timeline.
    The dates that the buttons lead to are in scene 2.
    In scene 1 is where the movie clip is. Because the line of dates is so long I have got two arrow keys that make the dates move left and right until the user finds their desired date, then by clicking on it it should take them to where they want to go in scene 2. DOes this make any sense?
    So the arrow keys are moving the line of dates and each of these dates are different buttons!!!!
    Let me know if I'm not making sense, sorry!

    Scene 1=
    MC of dates
    Arrows moving MC

    Scene 2=
    different areas the buttons lead to

  8. #8
    Junior Member
    Join Date
    May 2002
    Posts
    19
    I think I'm just bad at explaining!!
    Ok I have a MC that is made up of a lot of buttons. This movie clip is in scene 1. The destinations of the different buttons are in Scene2. As there are so many buttons there are 2 arrow keys on the screen in scene 1 that move the buttons left and right (I'm creating a historical timeline).
    Does this make any more sense?

    Scene 1 = MC and arrows
    Scene 2 = Butoon destinations

  9. #9
    Junior Member
    Join Date
    May 2002
    Posts
    19
    I keep writing replys but they're not showing up!

  10. #10
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    Ok, first things first. This is how to make the buttons in Scene 1 go to the destinations in Scene 2.

    First, add frame labels to the specific frames in Scene 2 that you want your buttons in Scene 1 to go to.

    Then add this code to your buttons in Scene 1:

    on (release) {
    gotoAndPlay("Scene 2", "dateLabel");
    }

    You need to change dateLabel to the actual frame label each time.

    Let me know how you get on...

  11. #11
    Junior Member
    Join Date
    May 2002
    Posts
    19
    thats no probs! get that bit! now what?, thank you

  12. #12
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    We're on a roll... What's left to do?

  13. #13
    Junior Member
    Join Date
    May 2002
    Posts
    19
    we've got the buttons going to their places in the movie clip, cool but when I put this movie clip into scene 1 and try to click on them it doesn't work, the hand symbol shows that the buttons are being recognised but when I try to click on them - you guessed it, nothing happens!!!!

  14. #14
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    Sorry, I forgot you wanted the buttons inside the movie clip.

    In that case change the button code to:

    on (release) {
    tellTarget ("../") {
    gotoAndPlay ("Scene 2", "dateLabel");
    }
    }

    Change dateLabel to the appropriate frame label.

    This should work fine, but only with the buttons nested in the movie clip. If you need the buttons to work on the main timeline, use the code I posted earlier.

    Hope this helps.

  15. #15
    Junior Member
    Join Date
    May 2002
    Posts
    19
    It works!
    Thank you for being patient with me and for helping.
    Melissa

  16. #16
    Registered User
    Join Date
    Feb 2001
    Posts
    184
    Pleasure, glad to have helped.

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