A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: funky rollovers

  1. #1
    Member
    Join Date
    May 2001
    Posts
    97
    This may be a simple question that i probably should know the answer to, but anyway.....

    I know how to make a button that, when rolled over a movie clip plays. Giving the effect that the button is animated. Some sites however, have there buttons programmed so that when the mouse rolls out of the button the movie clip reverses. Does anyone know how to do this?

    Spiderman

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    143
    there are probably many different ways of doing this, but the method i uses has always been reliable, so here goes. first have a movieclip with the animation you want, you don't need to animate both ways (i.e. forwards and backwards) just do the roll over half of the animation. then make a button on a different layer that is invisable, it only has an object in the 'hit' frame, it will show up on the timeline as a translucent object, but will not show up in the actual movie.

    now select the movieclip and click the actionscript editor, put in this code:-

    onClipEvent (load) {
    this.stop();
    }
    onClipEvent (enterFrame) {
    if (_root.buttonOver == "true") {
    this.gotoAndStop(this._currentframe+1);
    }
    if (_root.buttonOver == "false") {
    this.gotoAndStop(this._currentframe-1);
    }
    }

    now click the invisible button and put in this actionscript:-

    on (rollOver) {
    buttonOver = "true";
    }
    on (rollOut) {
    buttonOver = "false";
    }

    on the first frame of the movie put this action:-

    buttonOver = "false";

    or a script error could be produced, finally put a stop action on the last frame of the movieclip or it will loop. this will now make the movieclip play when the mouse is over the invisible button, and when you roll off the button, the movie clip will play backwards, reversing the animation.

    i hope this is easy to follow!!

  3. #3
    Member
    Join Date
    May 2001
    Posts
    97
    I have most of the above script written, but where do i get the 'buttonOver' line of text?

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    143
    buttonOver is just a variable name, if you use the setVariable action, just type the variable name in the top box, and the value in the bottom box, you can call it anything you like, buttonOver is just a name i had used in one of my movies.

  5. #5
    Member
    Join Date
    May 2001
    Posts
    97
    cheers!!!! that worked an absolute treat. That is exactly what im looking for!!

    Cheers

    Happy Spiderman

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