package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.filters.BevelFilter;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
import flash.text.*;
import mx.core.UIComponent;
public class icn extends UIComponent
{
[Embed(source='C:/WINDOWS/Fonts/trebuc.TTF', fontName='Treb', unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
private var Treb:Class
private var c1:uint
private var c2:uint
private var textColor:uint
private var _text:String
private var textSize:uint
private var text:TextField
private var shadowText:TextField
private var back:Sprite
private var g:Graphics
public function icn(text:String, c1:uint , c2:uint, textColor:uint):void
{
_text = text
this.textColor = textColor
this.c1 = c1
this.c2 = c2
textSize = 74
this.scaleX = 2
this.scaleY = 2
back = new Sprite()
addChild(back)
g = back.graphics
buildGrad(c1,c2)
var b:BevelFilter = new BevelFilter(2,45,0xffffff,1,0x000000,1,1.5,1.5,.75)
back.filters = [b]
var tf:TextFormat = new TextFormat("Treb",textSize,textColor)
tf.align = TextFormatAlign.CENTER
this.text = new TextField()
this.text.selectable = false
this.text.defaultTextFormat = tf
this.text.text = text
this.text.embedFonts = true
this.text.width = 128
addChild(this.text)
var out:BevelFilter = new BevelFilter(2,45,0xffffff,1,0x000000,1,1.5,1.5,.75)
var inner:BevelFilter = new BevelFilter(-2,45,0xffffff,1,0x000000,1,1.5,1.5,.75,1,"outer")
this.text.filters = [inner]
this.shadowText = new TextField()
this.shadowText.selectable = false
this.shadowText.defaultTextFormat = tf
this.shadowText.text = text
this.shadowText.embedFonts = true
this.shadowText.width = 128
addChild(shadowText)
var dp:DropShadowFilter = new DropShadowFilter( 4, 45, 0x000000, 1, 4, 4, .5, 3, true, true)
this.shadowText.filters = [dp]
TextSize = textSize
}
public function set C1 (value:uint):void
{
c1 = value
buildGrad(c1,c2)
}
public function set C2 (value:uint):void
{
c2 = value
buildGrad(c1,c2)
}
public function set TextColor (value:uint):void
{
textColor = value
TextSize = textSize
}
public function set TextSize (value:uint):void
{
textSize = value
var tf:TextFormat = new TextFormat("Treb",textSize,textColor)
tf.align = TextFormatAlign.CENTER
text.setTextFormat(tf)
text.autoSize = "center"
this.text.y = 64 - this.text.height/2
shadowText.setTextFormat(tf)
shadowText.autoSize = "center"
this.shadowText.y = 64 - this.shadowText.height/2
}
public function set Text (value:String):void
{
_text = value
text.text = _text
shadowText.text = _text
TextSize = textSize
}
private function buildGrad(co1:uint,co2:uint):void
{
g.clear()
var ma:Matrix = new Matrix()
ma.createGradientBox(320,256,0,-128,-128)
g.beginGradientFill("radial",[co1,co2],[1,1],[0,0xff],ma)
g.drawRect(0,0,128,128)
}
}
}