11 Replies Latest reply on Oct 3, 2008 1:19 PM by kglad

    Actionscript disables embedded button

    accelaGraphics
      I'm trying to create a screen-based flash presentation with menus that appear and disappear when buttons are rolled over. The menu I've created is a simple 2-frame movie clip named "pictureClip" (Alpha0 box on 1st frame, a working button in 2nd frame). Another button on the page named "Button1" has actionscript:

      on (rollOver) {
      pictureClip.gotoAndStop(2);
      }

      This works great - the embedded button in pictureClip goes to a website. BUT... applying a rollOut script to the movie clip stops the embedded button from working!

      on (rollOut) {
      this.gotoAndStop("1");
      }

      Is this just something that movie clips do? Should I investigate another method of menus that appear and disappear? I'll try anything.


        • 1. Re: Actionscript disables embedded button
          kglad Adobe Community Professional & MVP
          yes. mouse handlers assigned to a parent intercept mouse events that you may intend for a child.

          to remedy, you can use a mouse handlers for the parent (or child) and use a loop that checks for a hittest on the child (or parent).
          • 2. Re: Actionscript disables embedded button
            accelaGraphics Level 1
            Thanks for the quick response, kglad. I tried the hitTest, but I'm new to that function. My new script on the movie clip named "pictureClip" didn't turn that movie clip invisible, and still stopped the embedded button from working. How wrong did I get this, exactly?

            on (rollOut) {
            if (hitTest(_root._xmouse, _root._ymouse, false)) {
            this.gotoAndStop("1");
            }
            }
            • 3. Re: Actionscript disables embedded button
              kglad Adobe Community Professional & MVP
              i'm not sure what you should do, but that won't work.

              are you applying a mouse handler to the parent or the child?
              • 4. Re: Actionscript disables embedded button
                accelaGraphics Level 1
                I'm applying it to the parent. Actionscript forced me to add an "on...(something)", which I knew wouldn't work, but I don't even know, in plain English, what you were guiding me to do. I want the submenu (2 frame movie clip) to APPEAR when a MAIN menu item is rolled over, and make itself DISAPPEAR (by going to frame 1) when you roll OUT of the submenu. Seems easy, but it's taken me weeks to track down the specific code.

                So, in English, should I tell the submenu: if...hitTest true, then on rollOut, gotoAndStop(1)
                (where (1) is the frame of the submenu movie clip that's invisible)??

                Or maybe you mean for me to hitTest the child (the embedded button inside the submenu movie clip)?
                Like if...hitTest true, then...hmm, I really don't know what this would do, actually.

                Is there a Flash example, or tutorial, on this (seemingly common) use of Flash to create a multi-screen presentation? Thanks!
                • 5. Re: Actionscript disables embedded button
                  kglad Adobe Community Professional & MVP
                  in your parent's rollOut handler start a loop (like onMouseMove) and repeatedly check if you have positive hitTest with a child button (to check for a rollOver of the child) and check for a positive hittest AND a mousedown to check for a child press event.
                  • 6. Re: Actionscript disables embedded button
                    accelaGraphics Level 1
                    I've got this so far (doesn't work though - the movieclip still turns invisible, but the embedded button does nothing). There's not much documentation on the hitTest function that I can find, so sorry if I got this completely wrong again. I really appreciate these responses, kglad!

                    onClipEvent (mouseMove) {
                    this.onRollOut = function() {
                    this.gotoAndStop("1");
                    };
                    if (urlButton_btn.hitTest(_root._xmouse, _root._ymouse, true)) {
                    getURL(" http://www.adobe.com", "_self");
                    }
                    }
                    • 7. Re: Actionscript disables embedded button
                      kglad Adobe Community Professional & MVP
                      if you want to use a rollOver event on a parent and then start checking a child for a rollOut event you can use:

                      • 8. Re: Actionscript disables embedded button
                        accelaGraphics Level 1
                        I've been tweaking and staring at your code for hours, and something's not clicking. Really basic stuff - do I replace "parent" with the movieclip name, and "child" with the button name? Doesn't work either way. The debugger wants me to start the script with an "on..." handler. Also unclear what you mean by "//child rollout detected". I tried onRollOver for the child, but I'm not allowed to use nested "On..." handlers. Also, unsure about "delete this.onMouseMove". Really, truly sorry about my inexperience but this is a huge project that I can't even begin until this works.
                        • 9. Re: Actionscript disables embedded button
                          kglad Adobe Community Professional & MVP
                          if you're attaching code directly to an object, replace parent.onRollOver=function with on(rollOver). but the code i posted, attached to a frame, is preferable.

                          that's the only change you need to make to my code. where there are comments, you should add code to do what you want.
                          • 10. Re: Actionscript disables embedded button
                            accelaGraphics Level 1
                            Thanks for all the help, but this script is beyond me at this stage. I've decided to use 3-frame movie clips: invisible, light grey, dark grey (no more embedding of buttons). It still won't work!

                            I've got 2 movieclips on top of each other, named flyoutMovieClip3_mc and flyoutMovieClip4_mc. Rollover flyoutMovieClip3_mc and it darkens, rollout and it goes to Alpha0 EXCEPT when you're rolling over the other movieclip (flyoutMovieClip4_mc). And of course, a getURL action eventually for both. The (non-working) code:

                            on (rollOver) {
                            this.gotoAndStop("3");
                            if ((this.rollOut) && (flyoutMovieClip4_mc.rollOver)) {
                            this.gotoAndStop(2);
                            } else {
                            this.gotoAndStop("1");
                            }
                            }

                            (What happens is on rollover, it goes to frame 1, invisible. Why??)
                            • 11. Re: Actionscript disables embedded button
                              kglad Adobe Community Professional & MVP
                              because when your rollOver your movieclip, you're NOT rolling out of it.

                              so, you're directing it to frame "3" and then immediately to frame "1". and all you see is frame "1" because the stage doesn't update quickly enough to see a flicker of frame "3".