Draw a Linear Gradient


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Please note that the rotation is in radians!To convert from degrees to radians: degrees * Math.PI / 180;
  2.  
  3. var grad:String = GradientType.LINEAR;
  4. var linMatrix:Matrix = new Matrix( );
  5. var rotationDegrees:int = 90
  6. linMatrix.createGradientBox( WIDTH, HEIGHT, (rotationDegrees * Math.PI / 180) );
  7.  
  8. var colors:Array = [ Colors.GRAD_BLACK, Colors.GRAD_LIGHT_BLACK ];
  9. var alphas:Array = [ 1, 0.9 ];
  10. var ratios:Array = [ 0, 255 ];
  11. var focalPoint:Number = .0;
  12.  
  13. graphics.beginGradientFill( grad , colors , alphas , ratios , linMatrix , SpreadMethod.PAD, InterpolationMethod.RGB, focalPoint);
  14. graphics.drawRect( 0, 0, WIDTH -4 , HEIGHT);
  15. graphics.endFill( );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.