Profile.as

  1. /*
  2.  * Opciones generales
  3.  *
  4.  *
  5.  * ProInf.net, 2008
  6.  * GNU General Public License: http://creativecommons.org/licenses/GPL/2.0/deed.es
  7.  *
  8.  */
  9. class Profile implements Initiable {
  10.  
  11. //////////////////////////////////////////////////
  12. // Propiedades de la clase
  13.  
  14. private static var profile:Profile = null;
  15.  
  16. //////////////////////////////////////////////////
  17. // Propiedades
  18.  
  19. // Menú
  20. private var xStartMenu:Number = 0; // Posición de inicio del menú
  21. private var yStartMenu:Number = 0;
  22. private var offColorMenu:Number = 0x888888; //0xCCCCCC;
  23.  
  24. // Elemento del menú
  25. private var brickWidth:Number = 250;
  26. private var brickHeight:Number = 25;
  27.  
  28. // Destino
  29. private var defaultTargetWidth:Number = 550;
  30. private var defaultTargetHeight:Number = 400;
  31. private var defaultTargetColor:Number = 0xAAAAAA;
  32.  
  33. // Película
  34. private var background:String = null; // Color o imagen de fondo (1300x900 píxeles)
  35. private var animated:Boolean = true; // Realizar animaciones
  36.  
  37. //////////////////////////////////////////////////
  38. // Constructor
  39.  
  40. private function Profile() {
  41. }
  42.  
  43. public static function getInstance():Profile {
  44. if (profile == null) {
  45. profile = new Profile();
  46. }
  47. return profile;
  48. }
  49.  
  50. //////////////////////////////////////////////////
  51. // Destructor
  52.  
  53. /** Free resources. Call manually just before delete this class */
  54. public function die() {
  55. }
  56.  
  57. //////////////////////////////////////////////////
  58. // Getters
  59.  
  60. public function getXStartMenu():Number { return xStartMenu; }
  61. public function getYStartMenu():Number { return yStartMenu; }
  62. public function getOffColorMenu():Number { return offColorMenu; }
  63.  
  64. public function getBrickWidth():Number { return brickWidth; }
  65. public function getBrickHeight():Number { return brickHeight; }
  66.  
  67. public function getDefaultTargetWidth():Number { return defaultTargetWidth; }
  68. public function getDefaultTargetHeight():Number { return defaultTargetHeight; }
  69. public function getDefaultTargetColor():Number { return defaultTargetColor; }
  70.  
  71. public function getBackground():String { return background; }
  72. public function isAnimated():Boolean { return animated; }
  73.  
  74. public function setAnimatedFromString(on_off:String) {
  75. this.animated = Utils.clearUndefined(on_off, "off") == "on";
  76. }
  77.  
  78. //////////////////////////////////////////////////
  79. // Setters
  80.  
  81. public function setXStartMenu(valor:Number) { this.xStartMenu = valor; }
  82. public function setYStartMenu(valor:Number) { this.yStartMenu = valor; }
  83. public function setOffColorMenu(valor:Number) { this.offColorMenu = valor; }
  84.  
  85. public function setBrickWidth(valor:Number) { this.brickWidth = valor; }
  86. public function setBrickHeight(valor:Number) { this.brickHeight = valor; }
  87.  
  88. public function setBackground(valor:String) {
  89. this.background = valor;
  90. var rgb = Utils.parseColor(valor);
  91. if (rgb == NaN) { // Imagen de fondo
  92. _root.background.loadMovie(background);
  93. }
  94. else { // Color de fondo
  95. var backgroundColor:Color = new Color( _root.background );
  96. backgroundColor.setRGB(rgb);
  97. }
  98. }
  99. public function setAnimated(valor:Boolean) {
  100. this.animated = valor;
  101. }
  102.  
  103. //////////////////////////////////////////////////
  104. // Interfaz
  105.  
  106. public function init(xml:XML) {
  107. var root:XMLNode = xml.firstChild;
  108. if (root.nodeName == "menuxml") {
  109. getXMLNodeAttributes(root);
  110. }
  111. }
  112.  
  113. public function getXMLNodeAttributes(node:XMLNode) {
  114. if (node.attributes.animated != undefined) { setAnimatedFromString(node.attributes.animated); }
  115. if (node.attributes.background != undefined) { setBackground(node.attributes.background); }
  116. }
  117.  
  118.  
  119. //////////////////////////////////////////////////
  120. // Métodos propios
  121.  
  122. }

Proinf.net