home *** CD-ROM | disk | FTP | other *** search
- class com.argosy.ui.TreeMenu extends com.argosy.ui.baseUI
- {
- var menu_items;
- var menu_label;
- var drop_shadow;
- var side_image_loader;
- var side_image_holder;
- var dispatchEvent;
- var bg;
- static var normal_style;
- var menu_width = 175;
- var menu_height = 25;
- function TreeMenu()
- {
- super();
- }
- function clearContent()
- {
- this.menu = this.createEmptyMovieClip("menu",2);
- this.menu_items = [];
- }
- function setContent(items_array, label_str)
- {
- this.menu_label.htmlText = label_str;
- this.menu = this.createEmptyMovieClip("menu",2);
- this.menu_items = [];
- var _loc3_ = 0;
- while(_loc3_ < items_array.length)
- {
- var _loc6_ = this.menu.getNextHighestDepth();
- var _loc2_ = this.menu.createEmptyMovieClip("menu_" + _loc6_,_loc6_);
- _loc2_.title = items_array[_loc3_].title;
- _loc2_.image_url = items_array[_loc3_].image_url;
- _loc2_.type = items_array[_loc3_].type;
- _loc2_.parent = items_array[_loc3_].parent;
- _loc2_.pop_menu = items_array[_loc3_].pop_menu;
- _loc2_.top_parent = items_array[_loc3_].top_parent;
- _loc2_.activity_type = items_array[_loc3_].activity_type;
- _loc2_.activity_url = items_array[_loc3_].activity_url;
- _loc2_.mc_ref = items_array[_loc3_];
- _loc2_.showActivityText = items_array[_loc3_].showActivityText;
- _loc2_.color = _loc2_.type != "topmenu" ? _loc2_.mc_ref.top_parent.color : items_array[_loc3_].color;
- _loc2_.label_tf = _loc2_.createTextField("title",10,0,this.menu_height / 2 - 8,this.menu_width,12);
- _loc2_.label_tf.selectable = false;
- _loc2_.label_tf.html = true;
- _loc2_.label_tf.embedFonts = true;
- _loc2_.label_tf.styleSheet = com.argosy.ui.TreeMenu.normal_style;
- _loc2_.label_tf.htmlText = "<p><font color=\'#" + _loc2_.color + "\'>" + _loc2_.title + "</font></p>";
- _loc2_.bg = _loc2_.createEmptyMovieClip("bg",1);
- _loc2_.bg.lineStyle(1,0,100);
- _loc2_.bg.beginFill(16777215,100);
- com.drawing.drawUtil.drawRect(_loc2_.bg,0,0,this.menu_width,this.menu_height,0);
- _loc2_.bg.endFill();
- _loc2_.bg.filters = [this.drop_shadow];
- _loc2_.hl = _loc2_.createEmptyMovieClip("hl",2);
- _loc2_.hl.lineStyle(1,0,100);
- _loc2_.hl.beginFill("0x" + _loc2_.color,100);
- com.drawing.drawUtil.drawRect(_loc2_.hl,0,0,this.menu_width,this.menu_height,0);
- _loc2_.hl.endFill();
- _loc2_.hl._visible = false;
- trace("");
- trace(_loc2_.title);
- trace(_loc2_.activity_type);
- trace([_loc2_.type,_loc2_.showActivityText]);
- 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]]);
- trace("");
- if(_loc2_.type == "topmenu")
- {
- this.side_image_loader.clearImage();
- _loc2_.image_holder = _loc2_.createEmptyMovieClip("image_holder",100);
- _loc2_.image_holder._y = -250;
- _loc2_.image_loader = _loc2_.image_holder.attachMovie("ImageLoader","image_loader",1);
- _loc2_.image_loader.width = 175;
- _loc2_.image_loader.height = 230;
- _loc2_.image_loader.loadImage(_loc2_.image_url);
- _loc2_.image_loader.onRollOver = ascb.util.Proxy.create(this,this.menuOver,_loc2_);
- _loc2_.image_loader.onRollOut = _loc2_.bg.onReleaseOutside = ascb.util.Proxy.create(this,this.menuOut,_loc2_);
- _loc2_.image_loader.onPress = ascb.util.Proxy.create(this,this.menuPress,_loc2_);
- _loc2_.image_loader.onRelease = ascb.util.Proxy.create(this,this.menuRelease,_loc2_);
- _loc2_.image_loader.filters = [this.drop_shadow];
- }
- else if(_loc2_.type == "activity" && _loc2_.showActivityText || _loc2_.showActivityText)
- {
- var _loc5_ = _loc2_.mc_ref.top_parent.activity_text[_loc2_.activity_type];
- if(_loc5_ == undefined)
- {
- var _loc7_ = ["self_review","self_study","lab_practical"];
- _loc5_ = _loc2_.mc_ref.top_parent.activity_text[_loc7_[_loc3_]];
- }
- _loc2_.activity_text = _loc2_.createTextField("activity_text",_loc2_.getNextHighestDepth(),this.menu_width + 20,0,this.menu_width * 2,this.menu_height);
- _loc2_.activity_text.multiline = true;
- _loc2_.activity_text.wordWrap = true;
- _loc2_.activity_text.autoSize = true;
- _loc2_.activity_text.selectable = false;
- _loc2_.activity_text.html = true;
- _loc2_.activity_text.embedFonts = true;
- _loc2_.activity_text.styleSheet = com.argosy.ui.TreeMenu.normal_style;
- _loc2_.activity_text.htmlText = "<p><activity>" + _loc5_ + "</activity></p>";
- this.side_image_loader.loadImage(_loc2_.mc_ref.top_parent.sideimage);
- }
- else if(_loc2_.type != "topmenu")
- {
- this.side_image_loader.loadImage(_loc2_.mc_ref.top_parent.sideimage);
- }
- _loc2_.bg.onRollOver = ascb.util.Proxy.create(this,this.menuOver,_loc2_);
- _loc2_.bg.onRollOut = _loc2_.bg.onReleaseOutside = ascb.util.Proxy.create(this,this.menuOut,_loc2_);
- _loc2_.bg.onPress = ascb.util.Proxy.create(this,this.menuPress,_loc2_);
- _loc2_.bg.onRelease = ascb.util.Proxy.create(this,this.menuRelease,_loc2_);
- this.menu_items.push(_loc2_);
- if(items_array[_loc3_].active == false)
- {
- _loc2_.bg.enabled = false;
- _loc2_.bg._alpha = 10;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.layout_menu();
- }
- function layout_menu()
- {
- if(this.menu_items[0].type == "topmenu")
- {
- this.menu_label._x = 20;
- this.menu_label._width = this.width - 40;
- var _loc4_ = this.menu_width * this.menu_items.length;
- var _loc3_ = (this.width - _loc4_) / (this.menu_items.length + 1);
- var _loc2_ = 0;
- while(_loc2_ < this.menu_items.length)
- {
- this.menu_items[_loc2_]._x = _loc3_ + _loc3_ * _loc2_ + this.menu_width * _loc2_;
- this.menu_items[_loc2_]._y = this.height - this.menu_items[_loc2_].bg._height - 20;
- _loc2_ = _loc2_ + 1;
- }
- }
- else
- {
- this.menu_label._x = this.side_image_holder._x + this.side_image_holder._width + 10;
- this.menu_label._width = this.width - (this.menu_label._x - 10) * 2;
- _loc2_ = 0;
- while(_loc2_ < this.menu_items.length)
- {
- this.menu_items[_loc2_]._x = this.width / 2 - this.menu_width / 2;
- 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;
- _loc2_ = _loc2_ + 1;
- }
- }
- }
- function menuOver(mc)
- {
- mc.label_tf.htmlText = "<p><font color=\'#FFFFFF\'>" + mc.title + "</font></p>";
- mc.hl._visible = true;
- mc.image_holder.lineStyle(10,"0x" + mc.color,100,true,"normal","square","miter",2);
- com.drawing.drawUtil.drawRect(mc.image_holder,0,0,mc.image_holder._width,mc.image_holder._height,0);
- }
- function menuOut(mc)
- {
- mc.label_tf.htmlText = "<p><font color=\'#" + mc.color + "\'>" + mc.title + "</font></p>";
- mc.hl._visible = false;
- mc.image_holder.clear();
- }
- function menuPress(mc)
- {
- }
- function menuRelease(mc)
- {
- this.dispatchEvent({type:"selection",target:mc,button_type:mc.type,lastOwner:this});
- }
- function init()
- {
- if(com.argosy.ui.TreeMenu.normal_style == undefined)
- {
- com.argosy.ui.TreeMenu.normal_style = new TextField.StyleSheet();
- com.argosy.ui.TreeMenu.normal_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#1F3A70",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
- com.argosy.ui.TreeMenu.normal_style.setStyle("activity",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#1F3A70",textAlign:"left",textDecoration:"none",kerning:"true",letterSpacing:"0"});
- }
- super.init();
- }
- function createChildren()
- {
- this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,4,4,1,3,false,false,false);
- this.bg = this.createEmptyMovieClip("bg",1);
- this.menu = this.createEmptyMovieClip("menu",2);
- this.side_image_holder = this.createEmptyMovieClip("side_image_holder",200);
- this.side_image_holder._x = 30;
- this.side_image_holder.filters = [this.drop_shadow];
- this.side_image_loader = this.side_image_holder.attachMovie("ImageLoader","side_image_holder",1);
- this.side_image_loader.height = this.height;
- this.side_image_loader.width = 200;
- this.menu_label = this.createTextField("menu_label",1000,0,0,this.width,100);
- this.menu_label.selectable = false;
- this.menu_label.html = true;
- this.menu_label.embedFonts = true;
- this.menu_label.multiline = true;
- this.menu_label.wordWrap = true;
- this.menu_label.autoSize = true;
- this.menu_label.styleSheet = com.argosy.ui.TreeMenu.normal_style;
- }
- function layout()
- {
- this.bg.clear();
- this.bg.lineStyle(0,13421772,0);
- this.bg.beginFill(16711680,0);
- this.bg.lineTo(this.width,0);
- this.bg.lineTo(this.width,this.height);
- this.bg.lineTo(0,this.height);
- this.bg.lineTo(0,0);
- this.bg.endFill();
- }
- }
-