/ Published in: ActionScript 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * * Gradient Background * * usage: var myBg =new GradientBackground(100,100,0xffffff,0x000000,4,1); * params: width, height, top color, bottom color, corner radius, alpha * * @author Chuckanucka * @version1.0 **/ package com.chuck.effects{ // import needed classes import flash.display.MovieClip; import flash.display.Graphics; import flash.display.GradientType; import flash.display.SpreadMethod; import flash.geom.*; public class GradientBackground extends MovieClip { public function GradientBackground(bgWidth:Number,bgHeight:Number,topColor:Number=0xffffff,bottomColor:Number=0x000000,cornerRadius:Number=0,bgAlpha:Number=1) { // gradient defaults var gradType:String=GradientType.LINEAR; var gradAlphas:Array=[1,1]; var gradRatios:Array=[0,255]; var sprMethod:String=SpreadMethod.PAD; var gradColors:Array; gradColors=[topColor,bottomColor]; var gradMatrix:Matrix=new Matrix ; gradMatrix.createGradientBox(bgWidth,bgHeight,Math.PI/180*90,0,0); var newBg:MovieClip=new MovieClip ; var newGraphic:Graphics=newBg.graphics; newGraphic.beginGradientFill(gradType,gradColors,gradAlphas,gradRatios,gradMatrix,sprMethod); newGraphic.drawRoundRect(0,0,bgWidth,bgHeight,cornerRadius); newBg.alpha = bgAlpha addChild(newBg); } } }
URL: http://activeden.net/user/Chuckanucka/portfolio?ref=Chuckanucka