Guest User

Untitled

a guest
Oct 29th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.display.Shape;
  2. import flash.display.Graphics;
  3. import flash.display.GradientType;
  4. import flash.geom.Matrix;
  5. import flash.text.TextField;
  6. import flash.text.TextFormat;
  7.  
  8. var colors:Array = [0xADD205, 0xFFA01E, 0x028FDB];
  9. var n:int = colors.length;
  10. var w:int = 50; var h:int = 50;
  11. var s:Shape;
  12. var m:Matrix = new Matrix();
  13. m.createGradientBox(w, h, Math.PI/2);
  14.  
  15. label("flat colors", w, h - 20);
  16. label("flat >> web 2.0 glossy", w, h*3 - 20);
  17.  
  18. for(var i:int = 0; i < n; ++i)
  19. {
  20.     s = new Shape();
  21.     s.x = w + i*w; s.y = h;
  22.     s.graphics.beginFill(colors[i], 1);
  23.     s.graphics.drawRect(0, 0, w, h);
  24.     s.graphics.endFill();
  25.     addChild(s);
  26. }
  27.  
  28. for(i = 0; i < n; ++i)
  29. {
  30.     s = new Shape();
  31.     s.x = w + i*w; s.y = h*3;
  32.     s.graphics.beginGradientFill(GradientType.LINEAR, [scaleColor(colors[i], .3), scaleColor(colors[i], -.3)], [1, 1], [0, 255], m);
  33.     s.graphics.drawRect(0, 0, w, h);
  34.     s.graphics.endFill();
  35.     addChild(s);
  36. }
  37.  
  38. function scaleColor(c:uint, scale:Number):uint
  39. {
  40.     var r:int = (c & 0xFF0000) >> 16;
  41.     var g:int = (c & 0x00FF00) >> 8;
  42.     var b:int = c & 0x0000FF;
  43.     r += (255 * scale)*(r / (r+g+b)); r = (r > 255) ? 255 : r;
  44.     g += (255 * scale)*(g / (r+g+b)); g = (g > 255) ? 255 : g;
  45.     b += (255 * scale)*(b / (r+g+b)); b = (b > 255) ? 255 : b;
  46.     return (r << 16 & 0xff0000) + (g << 8 & 0x00ff00) + (b & 0x0000ff);
  47. }
  48.  
  49. function label(str:String, x:int, y:int):void
  50. {
  51.     var tf:TextField = new TextField();
  52.     tf.text = str; tf.x = x; tf.y = y;
  53.     tf.setTextFormat(new TextFormat("verdana", 10));
  54.     addChild(tf);
  55. }
Add Comment
Please, Sign In to add comment