3 Replies Latest reply on Jan 12, 2011 3:04 PM by kglad

    using script to add a button effect? possible?

    RedLine_24_12

      Hi @ all

       

       

      i have a question:

       

      is it possible to ad a "button effect" (different state for "normal" and "hover") to an existing button without having to do it graphically but only with a script?

       

      i ask this because i have a flash-gallery with hundrets of thumbinails in converted to buttons that recall a javascript to open the full image (lightbox) and it would be nice to add each button a nice "hover" effect (maybe they should look dark and become normal brightness when hovered) but i don't want to edit each single button ..

       

      maybe some AS that define such an effect that i have only to copy into each object??

       

       

      thanks a lot for the help, it's appreciated

        • 1. Re: using script to add a button effect? possible?
          kglad Adobe Community Professional & MVP

          you can't do what you want but you might be able to fake some effects.  as2 or as3?

          1 person found this helpful
          • 2. Re: using script to add a button effect? possible?
            RedLine_24_12 Level 1

            as2

             

            it's not really a matter of wich effect .. just want to have the gallery a bit more animating ..

            the best would be a brightness effect (button up: dark  ||  button hover and pressed: normal)

            • 3. Re: using script to add a button effect? possible?
              kglad Adobe Community Professional & MVP

              create something to overlay your button that gives you the rollover effect you want.  maybe a white rectangle with 50% alpha.  experiment.


              convert that to a movieclip and assign a linkage id (eg, over_mc).  you can then use:

               

              // 1.  you already have a button rollout you want to use:

               

              Button.prototype.attachMovie=MovieClip.prototype.attachMovie;

               

              b.onRollOver=function(){
                  mc = b.attachMovie("overID","over_mc",1,{_width:b._width,_height:b._height});
                  mc.onRollOut=b.onRollOut;
                  delete b.onRollOut;

              }
              b.onRollOut=function(){
                  b.over_mc.removeMovieClip();  // <- add this to your existing rollout
              }

               

              // 2.  you have no rollouts:

               

              Button.prototype.attachMovie=MovieClip.prototype.attachMovie;

               

              b.onRollOver=function(){
                  mc = b.attachMovie("overID","over_mc",1,{_width:b._width,_height:b._height});
                  mc.onRollOut=function(){
                      this.removeMovieClip();
                  }
              }