In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

gradation

Get Adobe Flash player
by Scmiz 29 May 2011
/**
 * Copyright Scmiz ( http://wonderfl.net/user/Scmiz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vKNQr
 */

package {
	import flash.display.Graphics;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
			drawBG(
				this.graphics,
				255, 100, 100,
				150, 50, 50
			);
        }
		
		private function drawBG(g:Graphics, topColorR:uint, topColorG:uint, topColorB:uint, bottomColorR:uint, bottomColorG:uint, bottomColorB:uint):void {
			g.clear();
			
			for (var index:uint = 0; index < 465; ++index) {
				var ratio:Number = Number(index) / 465;
				var ratioR:Number = 1.0 - ratio;
				var cr:uint = (topColorR * ratioR) + (bottomColorR * ratio);
				var cg:uint = (topColorG * ratioR) + (bottomColorG * ratio);
				var cb:uint = (topColorB * ratioR) + (bottomColorB * ratio);
				var color:uint = (cr << 16) + (cg << 8) + (cb << 0);
				
				g.beginFill(color);
				g.drawRect(0, 1 * index, 465, 1);
				g.endFill();
			}
		}
    }
}