4 Replies Latest reply on May 6, 2011 6:54 AM by kglad

    Trouble with Rollovers

    Psychomantis21

      I am trying to make a group or rollovers that display larger versions on images when you rollover their thumbnails. The problem is since everythign is in layers the bottom layers rollovers show up undernieth the other thumbnails. My whole website design is based on this and I want to avoid writing code for each individual rollover. Is there a way I can make it so all the rollovers apear over all teh other buttons?

        • 1. Re: Trouble with Rollovers
          kglad Adobe Community Professional & MVP

          as2 or as3?

          • 3. Re: Trouble with Rollovers
            relaxatraja Level 5

            for (i=1;i<=10;i++){

              this["item"+i].addEventListener(MouseEvent.ROLL_OVER, overfn);

            }

             

            function overfn(e:MouseEvent):void{

            e.target.gotoAndPlay("rollover");

            }

             

            Whereas item1...item10 are instance names of movieclip and e.target will target your relevant movieclip

            • 4. Re: Trouble with Rollovers
              kglad Adobe Community Professional & MVP

              if you already have so many rollovers defined that editing them is not practical, you can add another rollover to all your objects defined in the current scope at the time the following is excuted and this may work for you:

               

              var scope:MovieClip;

              swapDepths1(this);  // if "this" is the scope of your objects that have rollovers

               

              function swapDepths1(tl:MovieClip):void{

              scope=tl;

              for(var i:int=0;i<tl.numChildren;i++){

              var io:InteractiveObject=tl.getChildAt(i);

              if(io.hasEventListener(MouseEvent.ROLL_OVER)){

              io.addEventListener(MouseEvent.ROLL_OVER,swapDepths2);

              }

              }

              }

              function swapDepths2(e:MouseEvent):void{

              scope.addChild(e.currentTarget);  // assuming it's the thumb you want to move to the top and then scale

              //scope.addChild(e.currentTarget.largeImage);  // if the object to be scaled is the largeImage property of your thumb

              }