home *** CD-ROM | disk | FTP | other *** search
/ Practice Anatomy Lab / PAL.ISO / pc / PAL.swf / scripts / __Packages / com / argosy / ui / AlertBox.as < prev    next >
Encoding:
Text File  |  2007-03-19  |  5.2 KB  |  137 lines

  1. class com.argosy.ui.AlertBox extends com.argosy.ui.baseUI
  2. {
  3.    var passed_argurments;
  4.    var callback_owner;
  5.    var callback_name;
  6.    var title_tf;
  7.    var body_tf;
  8.    var yes_button;
  9.    var no_button;
  10.    var normal_style;
  11.    var mouseCatcher;
  12.    var bg;
  13.    var drop_shadow;
  14.    var bevel_filter;
  15.    var alert_width = 400;
  16.    function AlertBox()
  17.    {
  18.       super();
  19.    }
  20.    function setContent(title, body, confirm_text, cancel_text, event_owner, event_name)
  21.    {
  22.       trace("Alert setContent: " + arguments);
  23.       if(arguments.length > 6)
  24.       {
  25.          this.passed_argurments = arguments.splice(6,arguments.length);
  26.       }
  27.       else
  28.       {
  29.          this.passed_argurments = [];
  30.       }
  31.       this.callback_owner = event_owner;
  32.       this.callback_name = event_name;
  33.       this.title_tf.htmlText = "<p><title>" + title + "</title></p>";
  34.       this.body_tf.htmlText = "<p>" + body + "</p>";
  35.       this.yes_button.label = confirm_text;
  36.       if(cancel_text == null)
  37.       {
  38.          this.no_button._visible = false;
  39.       }
  40.       else
  41.       {
  42.          this.no_button._visible = true;
  43.          this.no_button.label = cancel_text;
  44.       }
  45.       this.layout_components();
  46.       this._visible = true;
  47.    }
  48.    function button_press_yes(evt)
  49.    {
  50.       trace("Alert Selection: " + arguments);
  51.       this.passed_argurments.push(true);
  52.       this.callback_owner[this.callback_name].apply(this.callback_owner,this.passed_argurments);
  53.       this._visible = false;
  54.    }
  55.    function button_press_no(evt)
  56.    {
  57.       trace("Alert Selection: " + arguments);
  58.       this.passed_argurments.push(false);
  59.       this.callback_owner[this.callback_name].apply(this.callback_owner,this.passed_argurments);
  60.       this._visible = false;
  61.    }
  62.    function init()
  63.    {
  64.       this.normal_style = new TextField.StyleSheet();
  65.       this.normal_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#333333",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  66.       this.normal_style.setStyle("title",{fontFamily:"Frutiger Bold",fontSize:"14",color:"#438CB8"});
  67.       super.init();
  68.       this._visible = false;
  69.    }
  70.    function createChildren()
  71.    {
  72.       this.mouseCatcher = this.createEmptyMovieClip("bg",1);
  73.       this.mouseCatcher.onPress = function()
  74.       {
  75.       };
  76.       this.mouseCatcher.useHandCursor = false;
  77.       this.bg = this.createEmptyMovieClip("bg",2);
  78.       this.title_tf = this._createTextField(this,"title_tf",5,0,0,this.width,20,this.normal_style,"");
  79.       this.body_tf = this._createTextField(this,"body_tf",6,0,0,this.width,20,this.normal_style,"");
  80.       this.body_tf.multiline = true;
  81.       this.body_tf.wordWrap = true;
  82.       this.body_tf.autoSize = true;
  83.       this.yes_button = this.attachMovie("CButton","yes_button",10);
  84.       this.yes_button.addEventListener("release",this,"button_press_yes",true);
  85.       this.yes_button.label = "OK";
  86.       this.no_button = this.attachMovie("CButton","yes_button",11);
  87.       this.no_button.addEventListener("release",this,"button_press_no",false);
  88.       this.no_button.label = "CANCEL";
  89.       this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,10,10,1,3);
  90.       this.bevel_filter = new flash.filters.BevelFilter(5,45,16777215,0.8,0,0.8,20,20,1,3,"inner",false);
  91.       this.bg.filters = [this.drop_shadow];
  92.       this.setSize(this.alert_width,100);
  93.    }
  94.    function layout_components()
  95.    {
  96.       this.title_tf._x = 5;
  97.       this.title_tf._y = 5;
  98.       this.body_tf._x = 5;
  99.       this.body_tf._y = this.title_tf._y + this.title_tf._height + 10;
  100.       this.yes_button._x = this.alert_width - this.yes_button._width - 5;
  101.       this.yes_button._y = this.body_tf._y + this.body_tf._height + 10;
  102.       this.no_button._x = this.yes_button._x - this.no_button._width - 5;
  103.       this.no_button._y = this.yes_button._y;
  104.       this.setSize(this.alert_width,this.no_button._y + this.no_button._height + 10);
  105.    }
  106.    function layout()
  107.    {
  108.       this.mouseCatcher.clear();
  109.       this.mouseCatcher._x = 0;
  110.       this.mouseCatcher._y = 0;
  111.       this.title_tf._width = this.alert_width - 10;
  112.       this.body_tf._width = this.alert_width - 10;
  113.       this.bg.clear();
  114.       var _loc3_ = new flash.geom.Matrix();
  115.       _loc3_.createGradientBox(this.width,this.height,1.5707963267948966,0,0);
  116.       this.bg.lineStyle(2,4426936,80);
  117.       this.bg.beginGradientFill("linear",[14409183,10856103],[100,100],[0,255],_loc3_,"pad");
  118.       this.bg.lineTo(this.width,0);
  119.       this.bg.lineTo(this.width,this.height);
  120.       this.bg.lineTo(0,this.height);
  121.       this.bg.lineTo(0,0);
  122.       this.bg.endFill();
  123.       this.bg.lineStyle(0,4426936,10,false,"normal","square","miter",8);
  124.       this.bg.moveTo(1,this.body_tf._y - 10);
  125.       this.bg.lineTo(this.width - 1,this.body_tf._y - 10);
  126.       var _loc2_ = {x:Stage.width / 2 - this.width / 2,y:Stage.height / 2 - this.height / 2};
  127.       this._parent.globalToLocal(_loc2_);
  128.       this._x = _loc2_.x;
  129.       this._y = _loc2_.y;
  130.       this.mouseCatcher._x = - this._x;
  131.       this.mouseCatcher._y = - this._y;
  132.       this.mouseCatcher.beginFill(16777215,20);
  133.       com.drawing.drawUtil.drawRect(this.mouseCatcher,0,0,this._parent._width,this._parent._height,0);
  134.       this.mouseCatcher.endFill();
  135.    }
  136. }
  137.