Greetings :P

Third appointment with the runtime drawing.
Third appointment with the Drawing API of Actionscript 3.0.
In this article, I will use the beginGradientFill mehod together with a Matrix similar to GradientBox.
As always, I invite you, once the script studied, to try yourself some experiments giving space to your fantasy...and...why not, if you fancy it, to publish them on the forum of this site, you are more then welcome and I would be pleased you do so :)

Let's get into the script...

I create a FLA and save it as 'disegno3.fla'.
I create a Document Class, an AS file saved as 'Disegno3.as', implemented the following way:
Code:
package
{
	import flash.display.MovieClip;
	import flash.display.GradientType;
	import flash.display.InterpolationMethod;
	import flash.display.SpreadMethod;
	import flash.geom.Matrix;
	import flash.events.Event;
	
	public class Disegno3 extends MovieClip
	{
		private var clip:MovieClip;

		private var colors_array:Array;
		private var rapporti_array:Array;
		
		private var sine:Number;
		private var angle:Number=0;

		public function Disegno3()
		{
			init();
		}
		
		private function init():void
		{
			stage.frameRate=31;
			
			colors_array=new Array('0xB16363','0x763A3A','0xECE9D8');
			rapporti_array=new Array(0,200,255);
			
			clip=new MovieClip();
			this.addChild(clip);
			
			this.addEventListener(Event.ENTER_FRAME,disegna);
		}
		
		private function disegna(e:Event):void
		{
			this.removeChild(clip);
			
			sine=Math.sin(angle)*20;
			
			var alphas:Array=new Array(sine,1,1);
			var matrix:Matrix=new Matrix();
			matrix.createGradientBox(200,100,sine,stage.stageWidth/4,stage.stageHeight/2);
			
			clip=new MovieClip();
			clip.graphics.clear();
			clip.graphics.beginGradientFill(GradientType.RADIAL,colors_array,alphas,
			rapporti_array,matrix,SpreadMethod.REFLECT,
			InterpolationMethod.RGB,.7);
			clip.graphics.lineTo(stage.stageWidth,0);
			clip.graphics.lineTo(stage.stageWidth,stage.stageHeight);
			clip.graphics.lineTo(0,stage.stageHeight);
			clip.graphics.endFill();
			
			angle+=.01;
			
			this.addChild(clip);
		}
	}
}
The result:







Let's analise the code.

Properties

a MovieClip into which I will design
private var clip:MovieClip;
an array containing the colors I wish to use
private var colors_array:Array;
an array containing the color distribution ratios.
private var rapporti_array:Array;
a numerical number containing the sinus
private var sine:Number;
a numerical value containing the value of the angle from which the sinus will be calculated and which will be increased
private var angle:Number=0;



Methods
init();
I impost the frame rate
stage.frameRate=31;
I initialize the colors array
colors_array=new Array('0xB16363','0x763A3A','0xECE9D8');
I initialize the ratios array
rapporti_array=new Array(0,200,255);
I create a new MovieClip and add it to the stage (otherwise it would not be visibile)
clip=new MovieClip();
this.addChild(clip);
I add a listener to the ENTER_FRAME which will call the method disegna() as many time by seconds based on the frame rate
this.addEventListener(Event.ENTER_FRAME,disegna);

disegna();
I remove the clip
NB: the fact of creating and then removing the clip, is necessary. At each interval, I remove the clip to free some memory and if I would not do so here in the function init, Flash would now give me an error as the clip would be equal to null.
this.removeChild(clip);
I calculate the angle's sinus (variable 'angle')
sine=Math.sin(angle)*20;
I create an array containing the alpha of each color used
var alphas:Array=new Array(sine,1,1);
I create a Matrix
var matrix:Matrix=new Matrix();
I define the type as GradientBox using the Matrix.createGradientBox class using 5 parameters: width, height, rotation, x and y.
matrix.createGradientBox(200,100,sine,stage.stageW idth/4,stage.stageHeight/2);
I create a new Movie Clip
clip=new MovieClip();
I clean up the MovieClip graphics
clip.graphics.clear();
I use the beginGradientFill using the following parameters:
- type of gradient (radial, linear?) passed using the static method RADIAL of the GradientType class
- an array containing the alpha values, so I pass the array_alphas
- an array containing the color distribution ratios, so I pass rapporti_array
- a matrix which would be ?matrix? of Box type
- a value to define the extension of the gradient. I use the static method REFLECT of the SpreadMethod class
- a value to define the interpolation of the gradient?s color. I use the static method RGB of the InterpolationMethod class
- a numerical value which points to the gradient's center
clip.graphics.beginGradientFill(GradientType.RADIA L,colors_array,alphas,rapporti_array,matrix,Spread Method.REFLECT,InterpolationMethod.RGB,.7);
I design with the clip
clip.graphics.lineTo(stage.stageWidth,0);
clip.graphics.lineTo(stage.stageWidth,stage.stageH eight);
clip.graphics.lineTo(0,stage.stageHeight);
clip.graphics.endFill();
I increase the angle
angle+=.01;
I add the clip to the DisplayObject
this.addChild(clip);

Have fun !