Web 2.0 Blue Gradient in Flash

March 23rd, 2008 § 0

After reading this tutorial here I implemented the gradient used in photoshop within flash. I wrote a quick little static class to create this as a six color gradient on the fly. Source Files   

//Gradient
 
package com.extralongfingers.utilities.visual
{
	import flash.display.Sprite;
	import flash.geom.Matrix;
	/**	 * @author Gregory Sogorka	 */
	public class BlueGradientBox
	{
		public function BlueGradientBox()
		{
			trace( "Ouch! I'm static. " );
		}
		public static function make( _target : Sprite, w : Number, h : Number, x : Number, y : Number, corner : Number ) : void
		{
			_target.graphics.lineStyle(1, 0x8c8c8c);
			//Colors and Ratios copied from Adobe Photoshop gradient presets.
			var colors : Array = [ 0x02a8e4, 	0x47bef0 , 	0x147bb6, 	0x005081, 	0x023761,	0x7295b5 	];
			var alphas : Array = [ 50, 	 		70, 		100 , 		100, 		100, 		100			];
			var ratios : Array = [ 15,  		19, 		77, 		136, 		248, 		254			];
			var matrix : Matrix	= new Matrix( );
			matrix.createGradientBox(w, h);
			_target.graphics.beginGradientFill("linear", colors, alphas, ratios, matrix);
			_target.graphics.drawRoundRect(x, y, w, h, corner, corner);
		}
	}
}
 





Where am I?

You are currently viewing the archives for March, 2008 at Meandering Thought.