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

  1. class com.argosy.ui.TreeMenu extends com.argosy.ui.baseUI
  2. {
  3.    var menu_items;
  4.    var menu_label;
  5.    var drop_shadow;
  6.    var side_image_loader;
  7.    var side_image_holder;
  8.    var dispatchEvent;
  9.    var bg;
  10.    static var normal_style;
  11.    var menu_width = 175;
  12.    var menu_height = 25;
  13.    function TreeMenu()
  14.    {
  15.       super();
  16.    }
  17.    function clearContent()
  18.    {
  19.       this.menu = this.createEmptyMovieClip("menu",2);
  20.       this.menu_items = [];
  21.    }
  22.    function setContent(items_array, label_str)
  23.    {
  24.       this.menu_label.htmlText = label_str;
  25.       this.menu = this.createEmptyMovieClip("menu",2);
  26.       this.menu_items = [];
  27.       var _loc3_ = 0;
  28.       while(_loc3_ < items_array.length)
  29.       {
  30.          var _loc6_ = this.menu.getNextHighestDepth();
  31.          var _loc2_ = this.menu.createEmptyMovieClip("menu_" + _loc6_,_loc6_);
  32.          _loc2_.title = items_array[_loc3_].title;
  33.          _loc2_.image_url = items_array[_loc3_].image_url;
  34.          _loc2_.type = items_array[_loc3_].type;
  35.          _loc2_.parent = items_array[_loc3_].parent;
  36.          _loc2_.pop_menu = items_array[_loc3_].pop_menu;
  37.          _loc2_.top_parent = items_array[_loc3_].top_parent;
  38.          _loc2_.activity_type = items_array[_loc3_].activity_type;
  39.          _loc2_.activity_url = items_array[_loc3_].activity_url;
  40.          _loc2_.mc_ref = items_array[_loc3_];
  41.          _loc2_.showActivityText = items_array[_loc3_].showActivityText;
  42.          _loc2_.color = _loc2_.type != "topmenu" ? _loc2_.mc_ref.top_parent.color : items_array[_loc3_].color;
  43.          _loc2_.label_tf = _loc2_.createTextField("title",10,0,this.menu_height / 2 - 8,this.menu_width,12);
  44.          _loc2_.label_tf.selectable = false;
  45.          _loc2_.label_tf.html = true;
  46.          _loc2_.label_tf.embedFonts = true;
  47.          _loc2_.label_tf.styleSheet = com.argosy.ui.TreeMenu.normal_style;
  48.          _loc2_.label_tf.htmlText = "<p><font color=\'#" + _loc2_.color + "\'>" + _loc2_.title + "</font></p>";
  49.          _loc2_.bg = _loc2_.createEmptyMovieClip("bg",1);
  50.          _loc2_.bg.lineStyle(1,0,100);
  51.          _loc2_.bg.beginFill(16777215,100);
  52.          com.drawing.drawUtil.drawRect(_loc2_.bg,0,0,this.menu_width,this.menu_height,0);
  53.          _loc2_.bg.endFill();
  54.          _loc2_.bg.filters = [this.drop_shadow];
  55.          _loc2_.hl = _loc2_.createEmptyMovieClip("hl",2);
  56.          _loc2_.hl.lineStyle(1,0,100);
  57.          _loc2_.hl.beginFill("0x" + _loc2_.color,100);
  58.          com.drawing.drawUtil.drawRect(_loc2_.hl,0,0,this.menu_width,this.menu_height,0);
  59.          _loc2_.hl.endFill();
  60.          _loc2_.hl._visible = false;
  61.          trace("");
  62.          trace(_loc2_.title);
  63.          trace(_loc2_.activity_type);
  64.          trace([_loc2_.type,_loc2_.showActivityText]);
  65.          trace([_loc2_.mc_ref,"  |  ",_loc2_.mc_ref.top_parent,"  |  ",_loc2_.mc_ref.top_parent.activity_text,"  |  ",_loc2_.mc_ref.top_parent.activity_text[_loc2_.activity_type]]);
  66.          trace("");
  67.          if(_loc2_.type == "topmenu")
  68.          {
  69.             this.side_image_loader.clearImage();
  70.             _loc2_.image_holder = _loc2_.createEmptyMovieClip("image_holder",100);
  71.             _loc2_.image_holder._y = -250;
  72.             _loc2_.image_loader = _loc2_.image_holder.attachMovie("ImageLoader","image_loader",1);
  73.             _loc2_.image_loader.width = 175;
  74.             _loc2_.image_loader.height = 230;
  75.             _loc2_.image_loader.loadImage(_loc2_.image_url);
  76.             _loc2_.image_loader.onRollOver = ascb.util.Proxy.create(this,this.menuOver,_loc2_);
  77.             _loc2_.image_loader.onRollOut = _loc2_.bg.onReleaseOutside = ascb.util.Proxy.create(this,this.menuOut,_loc2_);
  78.             _loc2_.image_loader.onPress = ascb.util.Proxy.create(this,this.menuPress,_loc2_);
  79.             _loc2_.image_loader.onRelease = ascb.util.Proxy.create(this,this.menuRelease,_loc2_);
  80.             _loc2_.image_loader.filters = [this.drop_shadow];
  81.          }
  82.          else if(_loc2_.type == "activity" && _loc2_.showActivityText || _loc2_.showActivityText)
  83.          {
  84.             var _loc5_ = _loc2_.mc_ref.top_parent.activity_text[_loc2_.activity_type];
  85.             if(_loc5_ == undefined)
  86.             {
  87.                var _loc7_ = ["self_review","self_study","lab_practical"];
  88.                _loc5_ = _loc2_.mc_ref.top_parent.activity_text[_loc7_[_loc3_]];
  89.             }
  90.             _loc2_.activity_text = _loc2_.createTextField("activity_text",_loc2_.getNextHighestDepth(),this.menu_width + 20,0,this.menu_width * 2,this.menu_height);
  91.             _loc2_.activity_text.multiline = true;
  92.             _loc2_.activity_text.wordWrap = true;
  93.             _loc2_.activity_text.autoSize = true;
  94.             _loc2_.activity_text.selectable = false;
  95.             _loc2_.activity_text.html = true;
  96.             _loc2_.activity_text.embedFonts = true;
  97.             _loc2_.activity_text.styleSheet = com.argosy.ui.TreeMenu.normal_style;
  98.             _loc2_.activity_text.htmlText = "<p><activity>" + _loc5_ + "</activity></p>";
  99.             this.side_image_loader.loadImage(_loc2_.mc_ref.top_parent.sideimage);
  100.          }
  101.          else if(_loc2_.type != "topmenu")
  102.          {
  103.             this.side_image_loader.loadImage(_loc2_.mc_ref.top_parent.sideimage);
  104.          }
  105.          _loc2_.bg.onRollOver = ascb.util.Proxy.create(this,this.menuOver,_loc2_);
  106.          _loc2_.bg.onRollOut = _loc2_.bg.onReleaseOutside = ascb.util.Proxy.create(this,this.menuOut,_loc2_);
  107.          _loc2_.bg.onPress = ascb.util.Proxy.create(this,this.menuPress,_loc2_);
  108.          _loc2_.bg.onRelease = ascb.util.Proxy.create(this,this.menuRelease,_loc2_);
  109.          this.menu_items.push(_loc2_);
  110.          if(items_array[_loc3_].active == false)
  111.          {
  112.             _loc2_.bg.enabled = false;
  113.             _loc2_.bg._alpha = 10;
  114.          }
  115.          _loc3_ = _loc3_ + 1;
  116.       }
  117.       this.layout_menu();
  118.    }
  119.    function layout_menu()
  120.    {
  121.       if(this.menu_items[0].type == "topmenu")
  122.       {
  123.          this.menu_label._x = 20;
  124.          this.menu_label._width = this.width - 40;
  125.          var _loc4_ = this.menu_width * this.menu_items.length;
  126.          var _loc3_ = (this.width - _loc4_) / (this.menu_items.length + 1);
  127.          var _loc2_ = 0;
  128.          while(_loc2_ < this.menu_items.length)
  129.          {
  130.             this.menu_items[_loc2_]._x = _loc3_ + _loc3_ * _loc2_ + this.menu_width * _loc2_;
  131.             this.menu_items[_loc2_]._y = this.height - this.menu_items[_loc2_].bg._height - 20;
  132.             _loc2_ = _loc2_ + 1;
  133.          }
  134.       }
  135.       else
  136.       {
  137.          this.menu_label._x = this.side_image_holder._x + this.side_image_holder._width + 10;
  138.          this.menu_label._width = this.width - (this.menu_label._x - 10) * 2;
  139.          _loc2_ = 0;
  140.          while(_loc2_ < this.menu_items.length)
  141.          {
  142.             this.menu_items[_loc2_]._x = this.width / 2 - this.menu_width / 2;
  143.             this.menu_items[_loc2_]._y = _loc2_ != 0 ? this.menu_items[_loc2_ - 1]._y + this.menu_items[_loc2_ - 1]._height + 10 : this.menu_label._y + this.menu_label._height + 10;
  144.             _loc2_ = _loc2_ + 1;
  145.          }
  146.       }
  147.    }
  148.    function menuOver(mc)
  149.    {
  150.       mc.label_tf.htmlText = "<p><font color=\'#FFFFFF\'>" + mc.title + "</font></p>";
  151.       mc.hl._visible = true;
  152.       mc.image_holder.lineStyle(10,"0x" + mc.color,100,true,"normal","square","miter",2);
  153.       com.drawing.drawUtil.drawRect(mc.image_holder,0,0,mc.image_holder._width,mc.image_holder._height,0);
  154.    }
  155.    function menuOut(mc)
  156.    {
  157.       mc.label_tf.htmlText = "<p><font color=\'#" + mc.color + "\'>" + mc.title + "</font></p>";
  158.       mc.hl._visible = false;
  159.       mc.image_holder.clear();
  160.    }
  161.    function menuPress(mc)
  162.    {
  163.    }
  164.    function menuRelease(mc)
  165.    {
  166.       this.dispatchEvent({type:"selection",target:mc,button_type:mc.type,lastOwner:this});
  167.    }
  168.    function init()
  169.    {
  170.       if(com.argosy.ui.TreeMenu.normal_style == undefined)
  171.       {
  172.          com.argosy.ui.TreeMenu.normal_style = new TextField.StyleSheet();
  173.          com.argosy.ui.TreeMenu.normal_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#1F3A70",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  174.          com.argosy.ui.TreeMenu.normal_style.setStyle("activity",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#1F3A70",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  175.       }
  176.       super.init();
  177.    }
  178.    function createChildren()
  179.    {
  180.       this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,4,4,1,3,false,false,false);
  181.       this.bg = this.createEmptyMovieClip("bg",1);
  182.       this.menu = this.createEmptyMovieClip("menu",2);
  183.       this.side_image_holder = this.createEmptyMovieClip("side_image_holder",200);
  184.       this.side_image_holder._x = 30;
  185.       this.side_image_holder.filters = [this.drop_shadow];
  186.       this.side_image_loader = this.side_image_holder.attachMovie("ImageLoader","side_image_holder",1);
  187.       this.side_image_loader.height = this.height;
  188.       this.side_image_loader.width = 200;
  189.       this.menu_label = this.createTextField("menu_label",1000,0,0,this.width,100);
  190.       this.menu_label.selectable = false;
  191.       this.menu_label.html = true;
  192.       this.menu_label.embedFonts = true;
  193.       this.menu_label.multiline = true;
  194.       this.menu_label.wordWrap = true;
  195.       this.menu_label.autoSize = true;
  196.       this.menu_label.styleSheet = com.argosy.ui.TreeMenu.normal_style;
  197.    }
  198.    function layout()
  199.    {
  200.       this.bg.clear();
  201.       this.bg.lineStyle(0,13421772,0);
  202.       this.bg.beginFill(16711680,0);
  203.       this.bg.lineTo(this.width,0);
  204.       this.bg.lineTo(this.width,this.height);
  205.       this.bg.lineTo(0,this.height);
  206.       this.bg.lineTo(0,0);
  207.       this.bg.endFill();
  208.    }
  209. }
  210.