home *** CD-ROM | disk | FTP | other *** search
/ Canadian Forces: Prepare for Takeoff as a Pilot / CF_FS_Air.iso.iso / pc / data / swf / flashpaper / 103.swf / scripts / MUIComponentSymbol.as < prev   
Text File  |  2004-06-30  |  5KB  |  166 lines

  1. function MUIComponentClass()
  2. {
  3.    this.init();
  4. }
  5. MUIComponentClass.prototype = new MovieClip();
  6. MUIComponentClass.prototype.init = function()
  7. {
  8.    this.enable = true;
  9.    this.focused = false;
  10.    this.useHandCursor = false;
  11.    this._accImpl = new Object();
  12.    this._accImpl.stub = true;
  13.    this.styleTable = new Array();
  14.    if(_global.globalStyleFormat == undefined)
  15.    {
  16.       _global.globalStyleFormat = new MStyleFormat();
  17.       globalStyleFormat.isGlobal = true;
  18.       _global._focusControl = new Object();
  19.       _global._focusControl.onSetFocus = function(oldFocus, newFocus)
  20.       {
  21.          oldFocus.myOnKillFocus();
  22.          newFocus.myOnSetFocus();
  23.       };
  24.       Selection.addListener(_global._focusControl);
  25.    }
  26.    if(this._name != undefined)
  27.    {
  28.       this._focusrect = false;
  29.       this.tabEnabled = true;
  30.       this.focusEnabled = true;
  31.       this.tabChildren = false;
  32.       this.tabFocused = true;
  33.       if(this.hostStyle == undefined)
  34.       {
  35.          globalStyleFormat.addListener(this);
  36.       }
  37.       else
  38.       {
  39.          this.styleTable = this.hostStyle;
  40.       }
  41.       this.deadPreview._visible = false;
  42.       this.deadPreview._width = this.deadPreview._height = 1;
  43.       this.methodTable = new Object();
  44.       this.keyListener = new Object();
  45.       this.keyListener.controller = this;
  46.       this.keyListener.onKeyDown = function()
  47.       {
  48.          this.controller.myOnKeyDown();
  49.       };
  50.       this.keyListener.onKeyUp = function()
  51.       {
  52.          this.controller.myOnKeyUp();
  53.       };
  54.       for(var i in this.styleFormat_prm)
  55.       {
  56.          this.setStyleProperty(i,this.styleFormat_prm[i]);
  57.       }
  58.    }
  59. };
  60. MUIComponentClass.prototype.setEnabled = function(enabledFlag)
  61. {
  62.    this.enable = arguments.length <= 0 ? true : enabledFlag;
  63.    this.tabEnabled = this.focusEnabled = enabledFlag;
  64.    if(!this.enable && this.focused)
  65.    {
  66.       Selection.setFocus(undefined);
  67.    }
  68. };
  69. MUIComponentClass.prototype.getEnabled = function()
  70. {
  71.    return this.enable;
  72. };
  73. MUIComponentClass.prototype.setSize = function(w, h)
  74. {
  75.    this.width = w;
  76.    this.height = h;
  77.    this.focusRect.removeMovieClip();
  78. };
  79. MUIComponentClass.prototype.setChangeHandler = function(chng, obj)
  80. {
  81.    this.handlerObj = obj != undefined ? obj : this._parent;
  82.    this.changeHandler = chng;
  83. };
  84. MUIComponentClass.prototype.invalidate = function(methodName)
  85. {
  86.    this.methodTable[methodName] = true;
  87.    this.onEnterFrame = this.cleanUI;
  88. };
  89. MUIComponentClass.prototype.cleanUI = function()
  90. {
  91.    if(this.methodTable.setSize)
  92.    {
  93.       this.setSize(this.width,this.height);
  94.    }
  95.    else
  96.    {
  97.       this.cleanUINotSize();
  98.    }
  99.    this.methodTable = new Object();
  100.    delete this.onEnterFrame;
  101. };
  102. MUIComponentClass.prototype.cleanUINotSize = function()
  103. {
  104.    for(var funct in this.methodTable)
  105.    {
  106.       this[funct]();
  107.    }
  108. };
  109. MUIComponentClass.prototype.drawRect = function(x, y, w, h)
  110. {
  111.    var inner = this.styleTable.focusRectInner.value;
  112.    var outer = this.styleTable.focusRectOuter.value;
  113.    if(inner == undefined)
  114.    {
  115.       inner = 16777215;
  116.    }
  117.    if(outer == undefined)
  118.    {
  119.       outer = 0;
  120.    }
  121.    this.createEmptyMovieClip("focusRect",1000);
  122.    this.focusRect.controller = this;
  123.    this.focusRect.lineStyle(1,outer);
  124.    this.focusRect.moveTo(x,y);
  125.    this.focusRect.lineTo(x + w,y);
  126.    this.focusRect.lineTo(x + w,y + h);
  127.    this.focusRect.lineTo(x,y + h);
  128.    this.focusRect.lineTo(x,y);
  129.    this.focusRect.lineStyle(1,inner);
  130.    this.focusRect.moveTo(x + 1,y + 1);
  131.    this.focusRect.lineTo(x + w - 1,y + 1);
  132.    this.focusRect.lineTo(x + w - 1,y + h - 1);
  133.    this.focusRect.lineTo(x + 1,y + h - 1);
  134.    this.focusRect.lineTo(x + 1,y + 1);
  135. };
  136. MUIComponentClass.prototype.pressFocus = function()
  137. {
  138.    this.tabFocused = false;
  139.    this.focusRect.removeMovieClip();
  140.    Selection.setFocus(this);
  141. };
  142. MUIComponentClass.prototype.drawFocusRect = function()
  143. {
  144.    this.drawRect(-2,-2,this.width + 4,this.height + 4);
  145. };
  146. MUIComponentClass.prototype.myOnSetFocus = function()
  147. {
  148.    this.focused = true;
  149.    Key.addListener(this.keyListener);
  150.    if(this.tabFocused)
  151.    {
  152.       this.drawFocusRect();
  153.    }
  154. };
  155. MUIComponentClass.prototype.myOnKillFocus = function()
  156. {
  157.    this.tabFocused = true;
  158.    this.focused = false;
  159.    this.focusRect.removeMovieClip();
  160.    Key.removeListener(this.keyListener);
  161. };
  162. MUIComponentClass.prototype.executeCallBack = function()
  163. {
  164.    this.handlerObj[this.changeHandler](this);
  165. };
  166.