Burst test

by tjoen
♥0 | Line 51 | Modified 2010-08-16 00:54:19 | MIT License
play

ActionScript3 source code

/**
 * Copyright tjoen ( http://wonderfl.net/user/tjoen )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mtS7
 */

package {
  import flash.display.AVM1Movie;
  import flash.display.Sprite;
  import flash.geom.Matrix;
  import flash.geom.Point; 
  import flash.filters.DropShadowFilter;
  import flash.text.TextField;                   

  public class Web2Badge extends Sprite {         

    private const LINE_COLOR:uint = 0x9999ff;
    private const BODY_COLOR1:uint = 0xff9999;
    private const BODY_COLOR2:uint = 0xffcc00; 
    private const CORNER:int = Math.random() * 20+5;
    private const RADIUS1:Number = Math.random() * 90+50; 
    private const RADIUS2:Number = Math.random() * 90+50; 
    private const TEXT:String = "WonderFL";

    public function Web2Badge () {
      var d:Number = Math.min(RADIUS1, RADIUS2) * 2;
              
      var s:Sprite = new Sprite();
      s.graphics.lineStyle(2, LINE_COLOR);AVM1Movie
      
      // scope and direction of the gradient contained Matrix object
      // (d × d the range of -45 ° direction)
      var matrix:Matrix = new Matrix();
      matrix.createGradientBox(d, d, -Math.PI / 4);
      
      // specify the gradient information
      s.graphics.beginGradientFill ("linear", // gradient of the linear
        [BODY_COLOR1, BODY_COLOR2], // color
        [1, 1],                      // transparency
        [50, 255],                    // position of the color
        matrix);                              // angle range and

      // star-shaped drawing
      var angle:Number = 2 * Math.PI / CORNER;
      var p1:Point, p2:Point;
  s.graphics.moveTo(RADIUS1, 0);
  for(var i:int = 0; i < CORNER; i++) {
    p1 = Point.polar(RADIUS2, angle * (i + 0.5));
    p2 = Point.polar(RADIUS1, angle * (i + 1));
    s.graphics.curveTo(p1.x, p1.y, p2.x, p2.y);
  }
  s.graphics.endFill();
      
      // put a shadow on it!
      s.filters = [new DropShadowFilter (4, 45, 0, 0.5)];

      // Create the text that appears in
      var size:int = d / TEXT.length-2;
      var text:TextField = new TextField();
      text.multiline = true;
      text.autoSize = "center";
      text.htmlText = '<font size="' + size + '" color = \"#000000\">'
        + '<b>CORNER='+ CORNER+'<br> RADIUS1='+ RADIUS1 + '<br> RADIUS='+ RADIUS2 + '<br>'  + TEXT + '</font></b>';
      text.x = -text.textWidth / 4;
      text.y = -text.textHeight / 2-1;
      text.filters = [new DropShadowFilter(1, 45, 0, 0.8)];
      s.addChild(text);
       s.x = s.y = 465/2;
      addChild(s);
    }
  }
}