A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Slide to the next Button menu

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    131

    Slide to the next Button menu

    Hi,
    I know this has probably been asked a billion times, but I am unsure what to search for and I am using a 56k, so every click takes hours.

    Basically, I have a vertical menu with 4 buttons. When I rollover a button an arrow appears from pointing to it, when I move over another button the arrow "slides" to that button...etc..

    OnRelease the arrow then sticks to that particluar button, showing which one I have clicked.

    Now, when I roll over another button the arrow then slides to where I have rolled over but when I roll out it returns back to the button I clicked,

    I hope this all makes sense
    Your help is certainly needed and appreciated
    thanks
    AD

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    The first part is easy. Put this ON the arrow clip.

    onClipEvent(enterFrame){
    this._y+=(_root.xpos-this._y)/7;
    }

    And on the button you just set the position it should go to.

    on(rollOver){
    _root.ypos=345;
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    something like this?
    Attached Files Attached Files

  4. #4
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    pellepiano, have not tried ya code yet but will ASAP

    gunko2, I Could not open your file.
    Using Flash MX on a MAC

  5. #5
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    PellePiano, Your code just seems to send the arrow to the top og the stage!?

    Could someone with MX 2004 unzip the file above and resave it as MX? THanks

  6. #6
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Sorry I missed a letter (typo).

    onClipEvent(enterFrame){
    this._y+=(_root.ypos-this._y)/7;
    }

    And on the button you just set the position it should go to.

    on(rollOver){
    _root.ypos=345;
    }

    You can also make it have a initial position, before a buttn jas been pressed, with...

    onClipEvent(load){
    // Initial position
    _root.ypos=440;
    }
    onClipEvent(enterFrame){
    this._y+=(_root.ypos-this._y)/7;
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  7. #7
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    Ok, now we're cookin.

    I do need a little explanation though. I understand that you set the starting postion and then when you roll over the button you are telling the variable _root.ypos to go to 345 but I thought you would need to name the arrow and tell that it needs to move or stay put...

    which leads me onto the next Question, how do I make the arrow stick to a button1 once it is clicked? But on rolling over button2 will make it move to that button and then on the roll out move back to button1?

    Catch me drift?

    Attached is the fla, I am running MX
    Attached Files Attached Files

  8. #8
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    The movieclip arrow is contantly "listening" to what the ypos variable is, if there is any change it goes there. As the code is ON the arrow ne instance names has to be used.

    This should work as a simple solution.....

    // On arrow
    onClipEvent(load){
    // Initial position
    _root.ypos=440;
    }
    onClipEvent(enterFrame){
    if(_root.button_status != "clicked")(
    this._y+=(_root.ypos-this._y)/7;
    }
    }

    //On the buttons
    on(rollOver){
    _root.button_status="not_clicked";
    _root.ypos=345;
    }
    on(realease){
    _root.button_status="clicked";
    _root.ypos=345;
    }

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  9. #9
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    Pellepiano your are so kind to help me like on this, I do appreciate it alot.

    I have got your code to work and I understand that you are saying - when the button is clicked move ypos to 345.

    This seems to stop the arrow near the button but not inline.

    What I am trying to make happen is when a button1 is "clicked" the arrow will be attached by an invisible magnet to button1, so when you roll over button2 the arrow will slide towards it but then return to button1 if you have not clicked on it.

    Maybe I should get back to my Colin Moock and read some more!?
    thank you again
    for you to see (MX)
    Attached Files Attached Files

  10. #10
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Yes, I was a little hasty there. The arrow probably freezes as you click.

    Dont have the time at the moment to figure out what you need, so it may be a good idea to delve more into actionscript.

    Some of what I wrote can be used, but you need a couple of more if statements.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  11. #11
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    hi, i posted a fla. example earlier in the post but u said u can't open it....
    so here is the code, just copy paste it to the first frame:
    code:

    mSpeed = 7;
    m2Speed = 15;
    MovieClip.prototype.mMove = function() {
    if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
    mXTarget = this._x;
    mGo = true;
    }
    _root.mcArrow._x += (mXTarget-_root.mcArrow._x)/m2Speed;
    };
    MovieClip.prototype.aMove = function() {
    if (mGo) {
    this._x += (mXTarget-this._x)/mSpeed;
    mGo = false;
    }
    };
    _root.mcArrow.onEnterFrame = function() {
    this.aMove();
    };
    for (nNum=1; nNum<=50; nNum++) {
    _root["mc"+nNum].onEnterFrame = function() {
    this.mMove();
    };
    }


    now all u have to do is create the arrow and give an instance name of mcArrow and create the menus and call it mc1, mc2, mc3....
    and that's it....
    if u have any questions i'm here (lol)

  12. #12
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    "and create the menus and call it mc1, mc2, mc3...."

    Gunko, I have not tried this as yet, buuuuuutt when you say:
    "and create the menus and call it mc1, mc2, mc3...."

    Do you mean create buttons and call them mc1, mc2, etc or create buttons and put them in a Movieclip?

    I have 4 buttons and one arrow, amounting to one menu.

    Thanks
    AD

  13. #13
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    Ok I got it working but still need to do this:

    "What I am trying to make happen is when button1 is "clicked" the arrow will be attached by an invisible magnet to button1, so when you roll over button2 the arrow will still slide towards it but when you roll out the button slides back to button1.

    Thanks =)
    AD

  14. #14
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    no, what i mean is that for exmaple u want to create a menu....
    u draw a form and turn it in to a movieclip (not a button)!
    and give it an instance name of mc1. if u want to create another menu u do the same thing only now u give an instance name of mc2 etc etc.
    if u have any questions don't afraid to ask.... cause i'm really bored....
    oh and one other thing.... if the menus are indside a movieclip that let's say has an instance name of mcMain then change the code in the part where the loop is (in the end) to:
    code:

    for(nNum=1;nNum<=50;nNum++){
    _root.mcMain["mc"+nNum].onEnterFrame = function():{
    this.mMove();
    };
    }


  15. #15
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    lol i didn't post fast enough.... u already got it working.... let me think how i can make the other thing u requested (the magnet)....
    i'll get back to u as soon as i will get it to work!

  16. #16
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    ok i have tried every thing i know (maybe i forgot something) and i can't make to work with the "magnet" affect - i'll keep trying though....
    mean while do u allow me to post the question in other forums? (what a stupid question i just asked lol)....

  17. #17
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    Go for your life!!!

    Where you from Gunko? US or UK

    Me UK just outside London

  18. #18
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    lol actually i'm from israel....

  19. #19
    Senior Member
    Join Date
    Mar 2001
    Posts
    131
    As your English was so good, and you are responding in my daytime I assumed you lived here!

    Just curious

  20. #20
    You again?!?!?! gunko2's Avatar
    Join Date
    Jun 2004
    Location
    Israel
    Posts
    171
    thanks for the compliment....
    if anyone answers me in the other forums i'll let u know....
    just check the board once in a while....

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