For a project I'm working on I'm trying to create a Flash file with a constantly color-shifting gradient that fills up the entire browser window. For a better explanation please see the following link:
Don't worry about the moving balls, those are just there to challenge the frameRate of the movie, which has a maximum of 60. If you look at the background you can see the gradient effect I'm referring to.
The method I'm currently using to create the gradient animation is a simple shape tween on the Flash timeline that tweens between shapes with different gradient colors. I'm definitely not achieving the performance I want using this technique.
So that's a long-winded way of asking what people think would be a better way to create such a color-shifting gradient while getting better performance? Some examples might be through bitmapData or using PixelBender, but I'm not versed enough in these techniques to know which would get me the best performance. Any help would be appreciated!
NOTE: In the comments below is a link to all of the project files used in the example posted above.
UPDATES:
I've posted an additional version of the example using zkarcher's code in place of my timeline-based gradient animation to compare the performance of each. It should be noted that my version (v1) is always playing the gradient while the code-based version (v2) only plays the gradient animation for 5 seconds each time you click.
As a new user I'm only allowed one link per post so please forgive the raw URLs
http://www.chrismalven.com/experiments/GradientTest/
http://www.chrismalven.com/experiments/GradientTest_v2/
For those interested in using a version of zkarcher's gradient-tweening code with TweenLite/TweenMax, replace the Tweener reference with the code below and be sure to import the TweenMax ColorTransform Plugin as well:
// Load the TweenMax Class Libraries import gs.*; import gs.easing.*; import gs.plugins.*; TweenPlugin.activate([ColorTransformPlugin]); TweenMax.to( bmp, // Object to tween changeSpeed, // Duration of the Tween {colorTransform: { redMultiplier: (o2.r-o1.r)/255.0, greenMultiplier: (o2.g-o1.g)/255.0, blueMultiplier: (o2.b-o1.b)/255.0, alphaMultiplier: 1, redOffset: o1.r, greenOffset: o1.g, blueOffset: o1.b, alphaOffset: 0 }, ease:Quad.easeOut, } );