5 Replies Latest reply on Apr 25, 2006 8:39 PM by kglad

    Animating a color change

    gryllsie
      I have a website that has a different color background on each section. My client wants the colors to blend smoothly together when clicking on a new section of the site, but as there are 9 sections I'm not sure I want to create zillions of blends and then the script to select which one would be appropriate at the time... not tricky, but a headache!

      Can I do this with actionscript somehow? ie defining the current colour and the colour to come, then instructing flash to do the transitional blend itself?

      Gryllsie
        • 1. Re: Animating a color change
          kglad Adobe Community Professional & MVP
          you can do that for movieclips. can you change your backgrounds into movieclips (if they are not already movieclips)?
          • 2. Re: Animating a color change
            gryllsie Level 1
            That's good to know, thanks. But how?!
            • 3. Re: Animating a color change
              kglad Adobe Community Professional & MVP
              the following code adds a new property to movieclips that lets you "fade" any movieclip from rgb1,alpha1 to rgb2,alpha2 in speed seconds using n steps. to apply to movieclip background2, use:

              background2.colorFadeF(rgb1,alpha1,rgb2,alpha2,speed,n);
              • 4. Re: Animating a color change
                gryllsie Level 1
                Wow, that looks scary! Can I just ask...

                The attached code sits as a frame action and the background2.colorFadeF(rgb1,alpha1,rgb2,alpha2,speed,n); sits in a button action? and how do I define the color? Is it as easy as changing some variables then calling the action?

                Thanks, and sorry for being a plank!
                • 5. Re: Animating a color change
                  kglad Adobe Community Professional & MVP
                  yes, that prototype code would usually be attached to the first frame of your main timeline. you should not and need not change anything in the attached code in the above message. just copy and paste that code to the first frame of your main timeline.

                  colorFadeF() could then be used from anywhere at any time in your swf. it could be part of a button/movieclip's mouse handler code or could be attached to a frame or anywhere that you want to use it.

                  if backgrounds have their color set by a color object and you want to fade background2 from background1's color to background2's color, you could use: