Create Gradient


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.