7 Replies Latest reply on Aug 2, 2009 2:11 PM by Ned Murphy

    A Rollover Button

    ForrestMorgan Level 1

      I have made a bitmap image into a rollover button - reason - so that when the mouse rolls over the hit area of the button/image/thumbnail - it becomes larger on the stage and when the mouse moves outside the paramaters of the larger picture it goes back down to the original button/image/thumbnail size.

       

      That works fine.

       

      However . . . there is always a however. When I implemented the same functions to the other thumbnails on the stage - if I rollover the second thumbnail  - the other thumbnails show up (through) on top of that enlarged image.

       

      I thought it was an 'order of layer problem' but that didn't fix it no matter how much I switched the layers around.

       

      I guess, like always, I'm missing one simple step.

       

      Can you help?

       

      Forrest

        • 1. Re: A Rollover Button
          Ned Murphy Adobe Community Professional & MVP

          You want to look into using swapDepths.  That will allow you to have each button move to the top when you interact with it.

          • 2. Re: A Rollover Button
            ForrestMorgan Level 1

            Sounds logical. However, I have looked and looked for swapDepth help - nothing. I have swapChildren, swapChildrenAt, and SWAP which has to do with streamPlay, etc.

             

            Curious, why it is so hard to get help from online tutorials whether in video or text??

             

            Please help again.

            Forrest

            • 3. Re: A Rollover Button
              Ned Murphy Adobe Community Professional & MVP

              In looking back I can't see what would have led me to think you were using AS2 instead of AS3... maybe it was just the term 'rollover'.  If you are using AS3 then you can look into either of the two things you found, or look into setChildIndex()...  setChildIndex may be the easier to work with because you can set it to the highest child depth ((numChildren-1) and not have to chase specific instances.  If you look up setChildIndex in the help docs you'll see it discusses exactly what you are trying to do (I think).

              • 4. Re: A Rollover Button
                ForrestMorgan Level 1

                Yes, I am using AS3 and thanks - I'll try that!

                Forrest

                 

                Date: Sat, 1 Aug 2009 17:38:33 -0600

                From: forums@adobe.com

                To: forrestmorgan@hotmail.com

                Subject: A Rollover Button

                 

                In looking back I can't see what would have led me to think you were using AS2 instead of AS3... maybe it was just the term 'rollover'.  If you are using AS3 then you can look into either of the two things you found, or look into setChildIndex()...  setChildIndex may be the easier to work with because you can set it to the highest child depth ((numChildren-1) and not have to chase specific instances.  If you look up setChildIndex in the help docs you'll see it discusses exactly what you are trying to do (I think).

                >

                • 5. Re: A Rollover Button
                  ForrestMorgan Level 1

                  Still working on it.

                  • 6. Re: A Rollover Button
                    ForrestMorgan Level 1

                    I tried the setChildIndex but no success.

                    I have this code written in my actions layer:

                     

                    //To have each picture enlarged when mouse is in their individual hit position with that picture then being on top of all the other pictures

                     

                    picOne_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

                     

                    picTwo_btn.addEventListener(MouseEvent.CLICK,buttonClicked);

                     

                    function buttonClicked(event:MouseEvent):void

                     

                    on (rollOver); this.swapDepth(1)
                    {
                        gotoAndStop(2);
                    }
                    on (rollOut)
                    {
                        gotoAndStop(1);
                    }

                     

                    1. I am getting an error message of "function does not have a body" - obviously I am missing code.

                    2. The 2nd picture (thumbnail) is still showing through the large rollover state of picture 1.

                     

                    Forrest

                    • 7. Re: A Rollover Button
                      Ned Murphy Adobe Community Professional & MVP

                      Okay, now you confused me...  You said you were using AS3 but I see AS2 code mixed with AS3 code... that will not work in any situation.  I do not see where you are using setChildIndex at all in that code.  You may want to check youyr publish settings to be sure of what version of actionscript your file thinks you are using, and then get everything to gel around whatever you decide to go with.

                       

                      As far as that first error message you mention, your code is errantly written, depsite having AS2 code intermixed... your function is not properly written in a general proper syntax sense...

                       

                      function function_name(function_arguments){

                           function_code

                      }