home *** CD-ROM | disk | FTP | other *** search
/ The Complete Idiot's Guide to Microsoft Excel 2010 / CIGExcel.iso / Videos / Flash / controller.swf / scripts / __Packages / mx / controls / Alert.as next >
Encoding:
Text File  |  2010-09-09  |  5.4 KB  |  179 lines

  1. class mx.controls.Alert extends mx.containers.Window
  2. {
  3.    var styleName;
  4.    var parent;
  5.    var _child0;
  6.    var __width;
  7.    var width;
  8.    var __height;
  9.    var height;
  10.    var border_mc;
  11.    var back_mc;
  12.    static var titleStyleDeclaration;
  13.    static var style;
  14.    static var messageStyleDeclaration;
  15.    static var buttonStyleDeclaration;
  16.    static var symbolOwner = mx.containers.Window;
  17.    static var version = "2.0.2.126";
  18.    static var buttonWidth = 50;
  19.    static var buttonHeight = 22;
  20.    static var okLabel = "OK";
  21.    static var yesLabel = "Yes";
  22.    static var noLabel = "No";
  23.    static var cancelLabel = "Cancel";
  24.    static var buttonUp = "ButtonSkin";
  25.    static var buttonDown = "ButtonSkin";
  26.    static var buttonOver = "ButtonSkin";
  27.    static var titleBackground = "TitleBackground";
  28.    static var buttonUpEmphasized = "ButtonSkin";
  29.    static var buttonOverEmphasized = "ButtonSkin";
  30.    static var buttonDownEmphasized = "ButtonSkin";
  31.    var className = "Alert";
  32.    var allowSize = false;
  33.    static var NONMODAL = 32768;
  34.    static var YES = 1;
  35.    static var NO = 2;
  36.    static var OK = 4;
  37.    static var CANCEL = 8;
  38.    static var P = _root;
  39.    function Alert()
  40.    {
  41.       super();
  42.    }
  43.    static function show(text, title, flags, parent, listener, icon, defButton)
  44.    {
  45.       var _loc2_ = new Object();
  46.       var _loc6_ = !(flags & mx.controls.Alert.NONMODAL) ? true : false;
  47.       if(parent == undefined)
  48.       {
  49.          var _loc0_ = null;
  50.          parent = _loc2_.parent = _root;
  51.       }
  52.       else
  53.       {
  54.          _loc2_.parent = parent;
  55.       }
  56.       _loc2_.okButton = !(flags & mx.controls.Alert.OK) ? false : true;
  57.       _loc2_.cancelButton = !(flags & mx.controls.Alert.CANCEL) ? false : true;
  58.       _loc2_.yesButton = !(flags & mx.controls.Alert.YES) ? false : true;
  59.       _loc2_.noButton = !(flags & mx.controls.Alert.NO) ? false : true;
  60.       _loc2_.defButton = defButton;
  61.       if(_loc2_.okButton == false && _loc2_.cancelButton == false && _loc2_.yesButton == false && _loc2_.noButton == false)
  62.       {
  63.          _loc2_.okButton = true;
  64.          _loc2_.defButton = mx.controls.Alert.OK;
  65.       }
  66.       _loc2_.title = title;
  67.       _loc2_.text = text;
  68.       _loc2_.icon = icon;
  69.       _loc2_.style = mx.controls.Alert.style;
  70.       _loc2_.skinTitleBackground = mx.controls.Alert.titleBackground;
  71.       _loc2_.titleStyleDeclaration = mx.controls.Alert.titleStyleDeclaration;
  72.       _loc2_.validateNow = true;
  73.       var _loc4_ = mx.managers.PopUpManager.createPopUp(parent,mx.controls.Alert,_loc6_,_loc2_);
  74.       if(_loc4_ == undefined)
  75.       {
  76.          trace("Failed to create a new alert, probably because there is no Alert in the Library");
  77.       }
  78.       _loc4_.addEventListener("click",listener);
  79.       return _loc4_;
  80.    }
  81.    function init(Void)
  82.    {
  83.       super.init();
  84.       this.visible = false;
  85.    }
  86.    function createChildren(Void)
  87.    {
  88.       if(mx.controls.Alert.messageStyleDeclaration != undefined)
  89.       {
  90.          this.styleName = mx.controls.Alert.messageStyleDeclaration;
  91.       }
  92.       var _loc3_ = mx.controls.alertClasses.AlertForm;
  93.       this.contentPath = _loc3_;
  94.       super.createChildren();
  95.    }
  96.    function getViewMetrics(Void)
  97.    {
  98.       var _loc2_ = super.getViewMetrics();
  99.       return _loc2_;
  100.    }
  101.    function doLayout(Void)
  102.    {
  103.       super.doLayout();
  104.    }
  105.    function draw(Void)
  106.    {
  107.       var _loc9_ = this.initializing;
  108.       super.draw();
  109.       if(_loc9_)
  110.       {
  111.          var _loc5_ = new Object();
  112.          _loc5_.x = this.parent._x;
  113.          _loc5_.y = this.parent._y;
  114.          this.parent.localToGlobal(_loc5_);
  115.          var _loc7_ = this.parent.width;
  116.          var _loc8_ = this.parent.height;
  117.          if(this.parent == _root && this.parent._parent == undefined || _loc7_ == undefined)
  118.          {
  119.             var _loc6_ = mx.managers.SystemManager.screen;
  120.             _loc7_ = _loc6_.width;
  121.             _loc8_ = _loc6_.height;
  122.             _loc5_.x = _loc6_.x;
  123.             _loc5_.y = _loc6_.y;
  124.          }
  125.          if(_global.isLivePreview)
  126.          {
  127.             return undefined;
  128.          }
  129.          _loc5_.x += (_loc7_ - this.width) / 2;
  130.          _loc5_.y += (_loc8_ - this.height) / 2;
  131.          this.parent.globalToLocal(_loc5_);
  132.          this.move(_loc5_.x,_loc5_.y);
  133.          if(this._child0.defButtonName != undefined)
  134.          {
  135.             this._child0[this._child0.defButtonName].setFocus();
  136.          }
  137.          else
  138.          {
  139.             this._child0.buttons[0].setFocus();
  140.          }
  141.       }
  142.    }
  143.    function size(Void)
  144.    {
  145.       if(_global.isLivePreview)
  146.       {
  147.          this.__width = this.width;
  148.          this.__height = this.height;
  149.       }
  150.       else
  151.       {
  152.          var _loc4_ = this._child0.getSize();
  153.          if(isNaN(_loc4_.width) || _loc4_.width < 20)
  154.          {
  155.             _loc4_.width = 96;
  156.          }
  157.          if(isNaN(_loc4_.height) || _loc4_.height < 20)
  158.          {
  159.             _loc4_.height = 66;
  160.          }
  161.          var _loc5_ = this.border_mc.borderMetrics;
  162.          if(!this.allowSize)
  163.          {
  164.             this.__width = _loc4_.width + 2 * _loc5_.left;
  165.             this.__height = _loc4_.height + _loc5_.top + _loc5_.bottom + this.back_mc.height;
  166.             this.allowSize = false;
  167.          }
  168.       }
  169.       super.size();
  170.    }
  171.    function setSize(w, h)
  172.    {
  173.       this.__width = w;
  174.       this.__height = h;
  175.       this.initializing = this.allowSize = true;
  176.       this.invalidate();
  177.    }
  178. }
  179.