Posted By

sidneydekoning on 05/14/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

trevorhartman
toxin20


Draw a Linear Gradient


 / Published in: ActionScript 3
 

  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  

You need to login to post a comment.