Posted By

dai on 04/29/10


Tagged

Fill gradient


Versions (?)

Create Gradient


 / Published in: ActionScript 3
 

If you’ve ever wanted to create a block of filled colour with a gradient for a background, similar to the standard Flex background

  1. var mat:Matrix = new Matrix();
  2. var bg:Sprite = new Sprite();
  3. mat.createGradientBox( stage.stageWidth, stage.stageHeight, Math.PI * .5 );
  4. bg.graphics.beginGradientFill( GradientType.RADIAL, [ 0xFFFFFF, 0xFF0000 ], [ 1, 1 ], [ 0, 255 ], mat );
  5. bg.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
  6. bg.graphics.endFill();
  7. addChild( bg );

Report this snippet  

You need to login to post a comment.