forked from: Gradient
forked from Gradient (diff: 1)
ActionScript3 source code
/**
* Copyright yangliu9812 ( http://wonderfl.net/user/yangliu9812 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/u4VS
*/
// forked from WLAD's Gradient
package {
import flash.display.Sprite;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.geom.Matrix;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
stage.addEventListener('mouseDown', function( e:* = null ):void
{
method = method == SpreadMethod.REFLECT ? SpreadMethod.PAD : SpreadMethod.REFLECT;
});
s = new Sprite();
addChild( s );
stage.addEventListener('enterFrame', draw );
draw();
}
private var s:Sprite;
private var t:Number = 0;
private var method:String = SpreadMethod.REFLECT;
private function draw( e:* = null ):void
{
t+=0.05; if( t > 1 ) t = 0;
var w:int = 465;
var h:int = 465;
var colors:Array = [0xFF00FF, 0xFF0000];
var alphas:Array = [0,1];
var ratios:Array = [20 + 155 * t,80 + int((255-80)*t)];
var mat:Matrix = new Matrix();
mat.createGradientBox( w/2, h/2, 0, -w / 4, -h / 4 );
s.graphics.clear();
s.graphics.beginGradientFill( GradientType.RADIAL, colors, alphas, ratios, mat, method );
s.graphics.drawRect(-w/2, -h/2, w, h );
s.graphics.endFill();
s.x = w/2;
s.y = h/2;
s.rotation += 5;
}
}
}
