Skip to main content
April 25, 2006
Question

Animating a color change

  • April 25, 2006
  • 4 replies
  • 345 views
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
This topic has been closed for replies.

4 replies

April 25, 2006
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!
kglad
Community Expert
Community Expert
April 26, 2006
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:



kglad
Community Expert
Community Expert
April 25, 2006
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);
April 25, 2006
That's good to know, thanks. But how?!
kglad
Community Expert
Community Expert
April 25, 2006
you can do that for movieclips. can you change your backgrounds into movieclips (if they are not already movieclips)?