Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.display.Shape;
- import flash.display.Graphics;
- import flash.display.GradientType;
- import flash.geom.Matrix;
- import flash.text.TextField;
- import flash.text.TextFormat;
- var colors:Array = [0xADD205, 0xFFA01E, 0x028FDB];
- var n:int = colors.length;
- var w:int = 50; var h:int = 50;
- var s:Shape;
- var m:Matrix = new Matrix();
- m.createGradientBox(w, h, Math.PI/2);
- label("flat colors", w, h - 20);
- label("flat >> web 2.0 glossy", w, h*3 - 20);
- for(var i:int = 0; i < n; ++i)
- {
- s = new Shape();
- s.x = w + i*w; s.y = h;
- s.graphics.beginFill(colors[i], 1);
- s.graphics.drawRect(0, 0, w, h);
- s.graphics.endFill();
- addChild(s);
- }
- for(i = 0; i < n; ++i)
- {
- s = new Shape();
- s.x = w + i*w; s.y = h*3;
- s.graphics.beginGradientFill(GradientType.LINEAR, [scaleColor(colors[i], .3), scaleColor(colors[i], -.3)], [1, 1], [0, 255], m);
- s.graphics.drawRect(0, 0, w, h);
- s.graphics.endFill();
- addChild(s);
- }
- function scaleColor(c:uint, scale:Number):uint
- {
- var r:int = (c & 0xFF0000) >> 16;
- var g:int = (c & 0x00FF00) >> 8;
- var b:int = c & 0x0000FF;
- r += (255 * scale)*(r / (r+g+b)); r = (r > 255) ? 255 : r;
- g += (255 * scale)*(g / (r+g+b)); g = (g > 255) ? 255 : g;
- b += (255 * scale)*(b / (r+g+b)); b = (b > 255) ? 255 : b;
- return (r << 16 & 0xff0000) + (g << 8 & 0x00ff00) + (b & 0x0000ff);
- }
- function label(str:String, x:int, y:int):void
- {
- var tf:TextField = new TextField();
- tf.text = str; tf.x = x; tf.y = y;
- tf.setTextFormat(new TextFormat("verdana", 10));
- addChild(tf);
- }
Add Comment
Please, Sign In to add comment