A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: rollout of movieclip

  1. #1

    rollout of movieclip

    This should be a simple question....

    I have a menu appear, which is a movie clip with will contain several links. The links will each be buttons with onRelease actions. What I want to do is make the menu disappear whenever the user moves the mouse away from the menu.

    I thought about creating an invisible button that is the same size as the background of the menu and then using an onRollout action. But I've had trouble trying this since you have the buttons for the menu items sitting on top of the button for the menu background.

    Doesn't Flash MX provide an easy way to do this with MovieClip events?

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    erm, are you looking for
    Code:
    MC.onRollOut = function() {
      //rollout code
    }

  3. #3
    I saw that in the user's guide, but it didn't work when I tried it.

    I had something like...

    MC.onRollOut = function() {
    gotoAndStop(1);
    }

    Would I need anything else?

  4. #4
    I think I answered my own question, but then came up with another one. :-)

    I used this code:
    onClipEvent (enterFrame) {
    this.onRollOut = function() {
    _parent.gotoAndStop(1);
    };
    }

    It worked, but I noticed something else. Whenever I move my mouse over any of the menu items (which are buttons), the onRollout code is executed. I guess since I've rolled onto another button, Flash determines that I've rolled off the menu clip. However, since my mouse is still in the menu area, I don't want to make it disappear.

    Any suggestions?

  5. #5
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    that'll work, but it'll gotoAndStop on the level the MC is on. if you wanted to gotoAndStop within the MC you need
    Code:
    MC.onRollOut = function() {
      MC.gotoAndStop(1);
    }

  6. #6
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    well, you always use hitTest to find out whether the mouse is over a specific area. There's an example just for that in the Help
    or you could mess aorund with boolean flags to see whether you're over a button or not
    or there might be a simpler solution, depending on how you've made it

  7. #7

    More strange results

    I'm making some progress although I'm still getting some strange results.

    Here's how my movie is setup:
    On my main timeline, I have a movieclip named "menu". The movieclip has the following actionscript on it:

    onClipEvent (load) {
    this.onRollOut = function() {
    this.gotoAndStop(1);
    };
    }

    Inside the "menu" movieclip, a list of buttons that serve as menu choices appears at frame 5.

    The intention of the above onClipEvent, is to make the list of menu choices disappear whenever the user rolls off the area of the menu movieclip.

    The rollout function is working; however, the buttons inside the movieclip no longer work. When I move my mouse over them, the mouse pointer changes to a hand, but when I click on them nothing happens. Additionally, the button is supposed to change colors as configured in the "Over" state, but that doesn't work either.

    As soon as I remove the onClipEvent code for the menu movieclip, the buttons all work as designed.

    Any suggestions?

  8. #8
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    i think this is because you're effectually trying to put buttons inside a button, and Flash doesn't like that. is this the effect you're trying to achieve?

    http://www.chistyler.com/hitvis.swf

  9. #9
    That is the effect I'm going for.

    Since my main menu movieclip is a movieclip and not a button, I wouldn't think the button-inside-a-button conflict would apply.

    Does putting an onClipEvent action on the movieclip make Flash consider it like a button?

  10. #10
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    the thing that makes Flash think it is a button is a rollOut or RollOver script or similar. that one i just did used a simple Mouse hitTest:
    Code:
    mouseListener = new Object();
    mouseListener.onMouseMove = function () {
    	if(hitTest( _root._xmouse, _root._ymouse, false)) {
    		menu._visible = 1;
    	}else{
    		menu._visible = 0;
    	}
    }
    Mouse.addListener(mouseListener);

  11. #11
    quick question - where would I put that code? On the main timeline, inside the menu movieclip or as an action for the movieclip itself?

  12. #12
    The world goes - hm.. TheCaramella's Avatar
    Join Date
    Dec 2001
    Location
    Second door on the right, next to the ice bear
    Posts
    642
    In the root level, on an Action script layer

  13. #13
    thanks to your help, I'm almost there. Actually it's working - I just want to put in a slight delay before the menu disappers.

    What I have so far is:
    mouseListener = new Object();
    mouseListener.onMouseMove = function () {
    if(hitTest( _root._xmouse, _root._ymouse, true))
    {
    stop();
    }else{
    if (menu.sublinks > 0) {
    menu.gotoAndPlay("off");
    }
    }
    }
    Mouse.addListener(mouseListener);

    How would I delay a few seconds before the menu.gotoAndPlay("off") gets executed?

  14. #14
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    i would add some frames before the required frame, and go to the first of those

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