InnerBackground.as 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package {
  2. import flash.display.Sprite;
  3. class InnerBackground extends Sprite {
  4. private var colour:Number=0;
  5. private var colour_2:Number=-1;
  6. private var angle:Number = 90;
  7. function InnerBackground( lv:Array )
  8. {
  9. if( lv.inner_background == undefined )
  10. return;
  11. var vals:Array = lv.inner_background.split(",");
  12. this.colour = _root.get_colour( vals[0] );
  13. trace( this.colour)
  14. if( vals.length > 1 )
  15. this.colour_2 = _root.get_colour( vals[1] );
  16. if( vals.length > 2 )
  17. this.angle = Number( vals[2] );
  18. this.mc = _root.createEmptyMovieClip( "inner_background", _root.getNextHighestDepth() );
  19. // create shadow filter
  20. var dropShadow = new flash.filters.DropShadowFilter();
  21. dropShadow.blurX = 5;
  22. dropShadow.blurY = 5;
  23. dropShadow.distance = 5;
  24. dropShadow.angle = 45;
  25. dropShadow.quality = 2;
  26. dropShadow.alpha = 0.5;
  27. // apply shadow filter
  28. // disabled for now...
  29. //this.mc.filters = [dropShadow];
  30. }
  31. function move( box:Box )
  32. {
  33. if( this.mc == undefined )
  34. return;
  35. this.mc.clear();
  36. this.mc.lineStyle(1, 0xFFFFFF, 0);
  37. if( this.colour_2 > -1 )
  38. {
  39. // Gradients: http://www.lukamaras.com/tutorials/actionscript/gradient-colored-movie-background-actionscript.html
  40. var fillType:String = "linear";
  41. var colors:Array = [this.colour, this.colour_2];
  42. var alphas:Array = [100, 100];
  43. var ratios:Array = [0, 255];
  44. var matrix = {matrixType:"box", x:0, y:0, w:box.width, h:box.height, r:this.angle/180*Math.PI};
  45. this.mc.beginGradientFill(fillType, colors, alphas, ratios, matrix);
  46. }
  47. else
  48. this.mc.beginFill( this.colour, 100);
  49. this.mc.moveTo(0, 0);
  50. this.mc.lineTo(box.width, 0);
  51. this.mc.lineTo(box.width, box.height);
  52. this.mc.lineTo(0, box.height);
  53. this.mc.lineTo(0, 0);
  54. this.mc.endFill();
  55. this.mc._x = box.left;
  56. this.mc._y = box.top;
  57. }
  58. }