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

  1. class com.argosy.ui.LabelHotSpot
  2. {
  3.    var leader_mc;
  4.    var white_leader;
  5.    var label_hl;
  6.    var pinFilter;
  7.    var color;
  8.    var glowFilter;
  9.    var hideFilter;
  10.    var leaderFilter;
  11.    var label_mc;
  12.    var snap_point;
  13.    var label_tf;
  14.    var dynamicLeader;
  15.    var label;
  16.    var type;
  17.    var pin_mc;
  18.    var dispatchEvent;
  19.    var id;
  20.    static var label_style;
  21.    static var hl_style;
  22.    static var color_array = [16777215,2479612,41210,10257403,14922492,64253,10288382];
  23.    var showAllOutlines = false;
  24.    var showAllLabels = false;
  25.    var showRollOvers = true;
  26.    function LabelHotSpot()
  27.    {
  28.       com.gskinner.events.GDispatcher.initialize(this);
  29.       if(com.argosy.ui.LabelHotSpot.label_style == undefined)
  30.       {
  31.          com.argosy.ui.LabelHotSpot.label_style = new TextField.StyleSheet();
  32.          com.argosy.ui.LabelHotSpot.label_style.setStyle("p",{fontFamily:"Univers Bold",fontSize:"13",color:"#000000",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  33.          com.argosy.ui.LabelHotSpot.label_style.setStyle("pin",{fontFamily:"Univers Bold",fontSize:"13",color:"#FFFFFF",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  34.          com.argosy.ui.LabelHotSpot.hl_style = new TextField.StyleSheet();
  35.          com.argosy.ui.LabelHotSpot.hl_style.setStyle("p",{fontFamily:"Univers Bold",fontSize:"13",color:"#005B93",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  36.       }
  37.    }
  38.    function set showLabels(b)
  39.    {
  40.       this.showAllLabels = b;
  41.       this.leader_mc._visible = this.showAllLabels;
  42.       this.white_leader._visible = this.showAllLabels;
  43.       this.label_hl._visible = this.showAllLabels;
  44.    }
  45.    function get showLabels()
  46.    {
  47.       return this.showAllLabels;
  48.    }
  49.    function set graphic(graphic_mc)
  50.    {
  51.       this.pinFilter = new flash.filters.DropShadowFilter(0,45,0,0.8,5,5,2,3,false,false,false);
  52.       if(this.color == 0)
  53.       {
  54.          this.glowFilter = new flash.filters.GlowFilter(com.argosy.ui.LabelHotSpot.color_array[this.color],0,2,2,10,4,true,true);
  55.       }
  56.       else
  57.       {
  58.          this.glowFilter = new flash.filters.GlowFilter(com.argosy.ui.LabelHotSpot.color_array[this.color],0.8,2,2,10,4,true,true);
  59.       }
  60.       this.hideFilter = new flash.filters.GlowFilter(0,0,0,0,1,1,true,true);
  61.       this.leaderFilter = new flash.filters.GlowFilter(16777215,0.8,2,2,10,3);
  62.       this.label_mc = graphic_mc;
  63.       this.label_mc.myObject = this;
  64.       this.snap_point = this.label_mc.snap_point;
  65.       this.snap_point._visible = false;
  66.       this.label_tf = this.label_mc.label_tf;
  67.       this.label_tf._visible = false;
  68.       if(this.label_mc.leader_mc == undefined)
  69.       {
  70.          this.leader_mc = this.label_mc.createEmptyMovieClip("leader_mc",this.label_mc.getNextHighestDepth());
  71.          this.dynamicLeader = true;
  72.       }
  73.       else
  74.       {
  75.          this.leader_mc = this.label_mc.leader_mc;
  76.          this.dynamicLeader = false;
  77.       }
  78.       if(this.leader_mc.white_leader == undefined)
  79.       {
  80.          this.white_leader = this.leader_mc.createEmptyMovieClip("white_leader",this.leader_mc.getNextHighestDepth());
  81.       }
  82.       else
  83.       {
  84.          this.white_leader = this.leader_mc.white_leader;
  85.       }
  86.       this.leader_mc.filters = [this.leaderFilter];
  87.       this.label_hl = this.label_mc.createEmptyMovieClip("label_hl",this.label_mc.getNextHighestDepth());
  88.       this.label_hl.tf = this.label_hl.createTextField("tf",1,0,0,this.label_mc.label_tf._width,this.label_mc.label_tf._height);
  89.       this.label_hl._x = this.label_mc.label_tf._x;
  90.       this.label_hl._y = this.label_mc.label_tf._y;
  91.       this.label_hl.tf.multiline = true;
  92.       this.label_hl.tf.autoSize = true;
  93.       this.label_hl.tf.background = false;
  94.       this.label_hl.tf.border = false;
  95.       this.label_hl.tf.html = true;
  96.       this.label_hl.tf.embedFonts = true;
  97.       this.label_hl.tf.selectable = true;
  98.       this.label_hl.tf.styleSheet = com.argosy.ui.LabelHotSpot.label_style;
  99.       this.label_hl.tf.htmlText = "<p>" + this.label + "</p>";
  100.       this.label_hl.filters = [this.leaderFilter];
  101.       if(this.type == "pin")
  102.       {
  103.          var _loc6_ = 30;
  104.          this.pin_mc = this.label_mc.createEmptyMovieClip("pin_mc",this.label_mc.getNextHighestDepth());
  105.          this.pin_mc._x = this.snap_point._x;
  106.          this.pin_mc._y = this.snap_point._y - _loc6_;
  107.          this.pin_mc.beginFill(6710886,100);
  108.          this.pin_mc.lineStyle(2,3355443,100,false,"none","square","miter",4);
  109.          this.pin_mc.moveTo(2,0);
  110.          this.pin_mc.lineTo(0,_loc6_);
  111.          this.pin_mc.lineStyle(2,13421772,100,false,"none","square","miter",4);
  112.          this.pin_mc.lineTo(-2,0);
  113.          this.pin_mc.lineStyle(1,13421772,100,false,"none","square","miter",4);
  114.          this.pin_mc.lineTo(2,0);
  115.          this.pin_mc.endFill();
  116.          this.pin_mc.lineStyle(1,0,100);
  117.          this.pin_mc.beginFill(2039399,100);
  118.          com.drawing.drawUtil.drawOval(this.pin_mc,0,0,8,8);
  119.          this.pin_mc.endFill();
  120.          if(this.label.length == 1)
  121.          {
  122.             this.pin_mc.tf = this.pin_mc.createTextField("tf",1,-5,-5,10,10);
  123.             this.pin_mc.tf.autoSize = true;
  124.             this.pin_mc.tf.html = true;
  125.             this.pin_mc.tf.embedFonts = true;
  126.             this.pin_mc.tf.selectable = false;
  127.             this.pin_mc.tf.styleSheet = com.argosy.ui.LabelHotSpot.label_style;
  128.             this.pin_mc.tf.htmlText = "<p><pin>" + this.label + "</pin></p>";
  129.             this.pin_mc.tf._x = - this.pin_mc.tf._width / 2;
  130.             this.pin_mc.tf._y = - this.pin_mc.tf._height / 2;
  131.          }
  132.          this.pin_mc._visible = this.showAllOutlines;
  133.          var _loc9_ = new flash.filters.GlowFilter(com.argosy.ui.LabelHotSpot.color_array[this.color],0.8,5,5,2,4,false,false);
  134.          this.pin_mc.filters = [_loc9_];
  135.       }
  136.       if(this.dynamicLeader)
  137.       {
  138.          var _loc3_ = 0;
  139.          var _loc5_ = this.label_hl._x + this.label_hl._width / 2;
  140.          var _loc4_ = this.label_hl._y + this.label_hl._height / 2;
  141.          var _loc8_ = _loc5_ + _loc3_ * (this.snap_point._x - _loc5_);
  142.          var _loc7_ = _loc4_ + _loc3_ * (this.snap_point._y - _loc4_);
  143.          this.leader_mc.lineStyle(2,0,50);
  144.          this.leader_mc.moveTo(_loc8_,_loc7_);
  145.          this.leader_mc.lineTo(this.snap_point._x,this.snap_point._y);
  146.       }
  147.       var _loc2_ = new Object();
  148.       _loc2_.x = this.label_hl._x;
  149.       _loc2_.y = this.label_hl._y;
  150.       this.label_mc.localToGlobal(_loc2_);
  151.       this.white_leader.globalToLocal(_loc2_);
  152.       _loc2_.x += 3;
  153.       _loc2_.y += 3;
  154.       this.white_leader.moveTo(_loc2_.x,_loc2_.y);
  155.       this.white_leader.beginFill(16711680,100);
  156.       this.white_leader.lineTo(_loc2_.x + this.label_hl._width - 6,_loc2_.y);
  157.       this.white_leader.lineTo(_loc2_.x + this.label_hl._width - 6,_loc2_.y + this.label_hl._height - 6);
  158.       this.white_leader.lineTo(_loc2_.x,_loc2_.y + this.label_hl._height - 6);
  159.       this.white_leader.lineTo(_loc2_.x,_loc2_.y);
  160.       this.white_leader.endFill();
  161.       this.leader_mc.blendMode = "layer";
  162.       this.white_leader.blendMode = "erase";
  163.       if(this.showAllOutlines)
  164.       {
  165.          if(this.type == "pin")
  166.          {
  167.             this.pin_mc._visible = true;
  168.             this.label_mc.hotspot.filters = [this.hideFilter];
  169.          }
  170.          else
  171.          {
  172.             this.label_mc.hotspot.filters = [this.glowFilter];
  173.          }
  174.       }
  175.       else
  176.       {
  177.          this.label_mc.hotspot.filters = [this.hideFilter];
  178.       }
  179.       if(!this.showAllLabels || this.label == undefined || this.type == "pin")
  180.       {
  181.          this.label_hl._visible = false;
  182.          this.leader_mc._visible = false;
  183.          this.white_leader._visible = false;
  184.       }
  185.       if(this.showRollOvers)
  186.       {
  187.          this.label_mc.onRollOver = this.label_mc.onDragOver = ascb.util.Proxy.create(this,this._rollOver);
  188.          this.label_mc.onRollOut = this.label_mc.onDragOut = ascb.util.Proxy.create(this,this._rollOut);
  189.          this.label_mc.onPress = ascb.util.Proxy.create(this,this._press);
  190.          this.label_mc.onRelease = ascb.util.Proxy.create(this,this._release);
  191.       }
  192.    }
  193.    function get graphic()
  194.    {
  195.       return this.label_mc;
  196.    }
  197.    function showHitTestOutline(mc)
  198.    {
  199.       if(mc != null && this.label_mc.hotspot.hitTest(_xmouse,_ymouse,true))
  200.       {
  201.          this.label_mc.hotspot.filters = [this.glowFilter];
  202.          return this.label_mc;
  203.       }
  204.       this.label_mc.hotspot.filters = [this.hideFilter];
  205.       return null;
  206.    }
  207.    function _rollOver()
  208.    {
  209.       if(this.type == "pin")
  210.       {
  211.          this.pin_mc.gotoAndStop(15);
  212.          this.pin_mc._visible = true;
  213.       }
  214.       else
  215.       {
  216.          this.label_mc.hotspot.filters = [this.glowFilter];
  217.       }
  218.       this.label_hl.tf.styleSheet = com.argosy.ui.LabelHotSpot.hl_style;
  219.       this.label_hl.tf.htmlText = "<p>" + this.label + "</p>";
  220.       this.leader_mc._visible = true;
  221.       this.white_leader._visible = true;
  222.       this.label_hl._visible = true;
  223.    }
  224.    function _rollOut()
  225.    {
  226.       if(!this.showAllOutlines)
  227.       {
  228.          if(this.type == "pin")
  229.          {
  230.             this.pin_mc._visible = false;
  231.          }
  232.          else
  233.          {
  234.             this.label_mc.hotspot.filters = [this.hideFilter];
  235.          }
  236.       }
  237.       this.label_hl.tf.styleSheet = com.argosy.ui.LabelHotSpot.label_style;
  238.       this.label_hl.tf.htmlText = "<p>" + this.label + "</p>";
  239.       if(!this.showAllLabels)
  240.       {
  241.          this.leader_mc._visible = false;
  242.          this.white_leader._visible = false;
  243.          this.label_hl._visible = false;
  244.       }
  245.    }
  246.    function _press()
  247.    {
  248.       this.dispatchEvent({type:"press",target:this,id:this.id});
  249.    }
  250.    function _release()
  251.    {
  252.       this.dispatchEvent({type:"release",target:this,id:this.id});
  253.    }
  254. }
  255.