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

  1. class com.argosy.ui.PopMenu extends com.argosy.ui.baseUI
  2. {
  3.    var bg;
  4.    var drop_shadow;
  5.    var menu_items;
  6.    var title;
  7.    var active;
  8.    var instructions;
  9.    var top_parent;
  10.    var stage_x;
  11.    var dispatchEvent;
  12.    var selected_mc;
  13.    static var normal_style;
  14.    static var over_style;
  15.    static var selected_style;
  16.    var type = "menu";
  17.    var menu_height = 25;
  18.    function PopMenu()
  19.    {
  20.       super();
  21.    }
  22.    function show(state)
  23.    {
  24.       if(state)
  25.       {
  26.          this.bg.filters = [this.drop_shadow];
  27.          this._visible = true;
  28.       }
  29.       else
  30.       {
  31.          this.bg.filters = [];
  32.          this._visible = false;
  33.          this.setMenuOver(null);
  34.       }
  35.       for(var _loc2_ in this.menu_items)
  36.       {
  37.          if(this.menu_items[_loc2_].type == "menu")
  38.          {
  39.             this.menu_items[_loc2_].pop_menu.show(false);
  40.          }
  41.       }
  42.    }
  43.    function setContent(node)
  44.    {
  45.       this.title = node.attributes.title;
  46.       if(this.active != false)
  47.       {
  48.          this.active = node.attributes.active == undefined || node.attributes.active == "true";
  49.       }
  50.       if(node.attributes.instructions != undefined)
  51.       {
  52.          this.instructions = "<p><font face=\'Frutiger Bold\' size=\'24\' color=\'#" + this.top_parent.color + "\'>" + node.attributes.title + "</font><br/><br/>" + "<font face=\'Frutiger Bold\' size=\'12\' color=\'#000000\'>" + node.attributes.instructions + "</font></p>";
  53.       }
  54.       else
  55.       {
  56.          this.instructions = "<p><font face=\'Frutiger Bold\' size=\'24\' color=\'#" + this.top_parent.color + "\'>" + node.attributes.title + "</font><br/><br/></p>";
  57.       }
  58.       this.menu_items = [];
  59.       var _loc5_ = 0;
  60.       while(_loc5_ < node.childNodes.length)
  61.       {
  62.          if(node.childNodes[_loc5_].nodeName != "activityText")
  63.          {
  64.             var _loc3_ = node.childNodes[_loc5_];
  65.             var _loc8_ = this.getNextHighestDepth();
  66.             var _loc2_ = this.createEmptyMovieClip("menu_" + _loc8_,_loc8_);
  67.             _loc2_.title = _loc3_.attributes.title;
  68.             _loc2_.showActivityText = _loc3_.attributes.activityText == "true";
  69.             _loc2_.label_tf = _loc2_.createTextField("title",10,0,4,this.width,12);
  70.             _loc2_.label_tf.selectable = false;
  71.             _loc2_.label_tf.html = true;
  72.             _loc2_.label_tf.embedFonts = true;
  73.             _loc2_.label_tf.styleSheet = com.argosy.ui.PopMenu.normal_style;
  74.             _loc2_.label_tf.htmlText = "<p>" + _loc2_.title + "</p>";
  75.             if(this.active == false || _loc3_.attributes.active == "false")
  76.             {
  77.                _loc2_.active = false;
  78.                _loc2_.label_tf._alpha = 50;
  79.             }
  80.             _loc2_.bg = _loc2_.createEmptyMovieClip("bg",1);
  81.             _loc2_.bg.lineStyle(0,0,0);
  82.             _loc2_.bg.beginFill(0,0);
  83.             _loc2_.bg.moveTo(1,0);
  84.             _loc2_.bg.lineTo(this.width,0);
  85.             _loc2_.bg.lineTo(this.width,this.menu_height);
  86.             _loc2_.bg.lineTo(1,this.menu_height);
  87.             _loc2_.bg.lineTo(1,0);
  88.             _loc2_.bg.endFill();
  89.             if(_loc5_ < node.childNodes.length - 1)
  90.             {
  91.                var _loc7_ = new flash.geom.Matrix();
  92.                _loc7_.createGradientBox(this.width,20,0,0,0);
  93.                _loc2_.bg.beginGradientFill("linear",[6710886,6710886,6710886],[0,100,0],[0,128,255],_loc7_,"pad");
  94.                _loc2_.bg.moveTo(20,this.menu_height);
  95.                _loc2_.bg.lineTo(this.width - 20,this.menu_height);
  96.                _loc2_.bg.lineTo(this.width - 20,this.menu_height + 1);
  97.                _loc2_.bg.lineTo(20,this.menu_height + 1);
  98.                _loc2_.bg.lineTo(20,this.menu_height);
  99.                _loc2_.bg.endFill();
  100.             }
  101.             _loc2_.hl = _loc2_.createEmptyMovieClip("hl",2);
  102.             _loc2_.hl.lineStyle(0,0,0);
  103.             _loc7_ = new flash.geom.Matrix();
  104.             _loc7_.createGradientBox(this.width,this.menu_height,1.5707963267948966,0,0);
  105.             var _loc4_ = "0x" + this.top_parent.color;
  106.             _loc2_.hl.beginGradientFill("linear",[_loc4_,_loc4_,_loc4_,_loc4_],[10,100,100,10],[0,64,192,255],_loc7_,"pad");
  107.             _loc2_.hl.moveTo(1,0);
  108.             _loc2_.hl.lineTo(this.width,0);
  109.             _loc2_.hl.lineTo(this.width,this.menu_height);
  110.             _loc2_.hl.lineTo(1,this.menu_height);
  111.             _loc2_.hl.lineTo(1,0);
  112.             _loc2_.hl.endFill();
  113.             _loc2_.hl._visible = false;
  114.             _loc2_.bg.onRollOver = ascb.util.Proxy.create(this,this.menuOver,_loc2_);
  115.             _loc2_.bg.onRollOut = ascb.util.Proxy.create(this,this.menuOut,_loc2_);
  116.             _loc2_.bg.onPress = ascb.util.Proxy.create(this,this.menuPress,_loc2_);
  117.             _loc2_.bg.onRelease = _loc2_.bg.onReleaseOutside = ascb.util.Proxy.create(this,this.menuRelease,_loc2_);
  118.             if(_loc3_.nodeName == "activity")
  119.             {
  120.                _loc2_.type = "activity";
  121.                _loc2_.parent = this;
  122.                _loc2_.activity_type = _loc3_.attributes.type;
  123.                _loc2_.activity_url = _loc3_.attributes.url;
  124.                _loc2_.top_parent = this.top_parent;
  125.                if(!this.active)
  126.                {
  127.                   _loc2_.bg.enabled = false;
  128.                   _loc2_._alpha = 50;
  129.                }
  130.             }
  131.             else
  132.             {
  133.                _loc2_.type = "menu";
  134.                _loc2_.pop_menu = _loc2_.attachMovie("PopMenu","pop_menu",100);
  135.                _loc2_.pop_menu.parent = this;
  136.                _loc2_.pop_menu.stage_x = this.stage_x;
  137.                _loc2_.pop_menu.addEventListener("selection",this,"bubbleEvent");
  138.                _loc2_.pop_menu.width = this.width;
  139.                _loc2_.top_parent = this.top_parent;
  140.                _loc2_.pop_menu.top_parent = this.top_parent;
  141.                if(this.active == false)
  142.                {
  143.                   _loc2_.pop_menu.active = false;
  144.                }
  145.                if(this.stage_x + this.width * 2 >= Stage.width)
  146.                {
  147.                   _loc2_.pop_menu._x = - this.width;
  148.                   _loc2_.pop_menu.stage_x = this.stage_x - this.width;
  149.                }
  150.                else
  151.                {
  152.                   _loc2_.pop_menu._x = this.width;
  153.                   _loc2_.pop_menu.stage_x = this.stage_x + this.width;
  154.                }
  155.                _loc2_.pop_menu.setContent(_loc3_);
  156.             }
  157.             this.menu_items.push(_loc2_);
  158.          }
  159.          _loc5_ = _loc5_ + 1;
  160.       }
  161.       _loc5_ = 0;
  162.       while(_loc5_ < this.menu_items.length)
  163.       {
  164.          this.menu_items[_loc5_]._y = _loc5_ * this.menu_height;
  165.          _loc5_ = _loc5_ + 1;
  166.       }
  167.       this.height = this.menu_items[this.menu_items.length - 1]._y + this.menu_height;
  168.    }
  169.    function bubbleEvent(evt)
  170.    {
  171.       evt.lastOwner = this;
  172.       this.dispatchEvent(evt);
  173.    }
  174.    function getHitTest()
  175.    {
  176.       return this.hitTest(this._xmouse,this._ymouse);
  177.    }
  178.    function setMenuOver(mc)
  179.    {
  180.       for(var _loc3_ in this.menu_items)
  181.       {
  182.          this.menu_items[_loc3_].label_tf.styleSheet = com.argosy.ui.PopMenu.normal_style;
  183.          this.menu_items[_loc3_].label_tf.htmlText = "<p>" + this.menu_items[_loc3_].title + "</p>";
  184.          this.menu_items[_loc3_].hl._visible = false;
  185.          this.menu_items[_loc3_].pop_menu.show(false);
  186.       }
  187.       mc.label_tf.styleSheet = com.argosy.ui.PopMenu.over_style;
  188.       mc.label_tf.htmlText = "<p>" + mc.title + "</p>";
  189.       mc.hl._visible = true;
  190.       mc.pop_menu.show(true);
  191.       this.selected_mc = mc;
  192.    }
  193.    function menuOver(mc)
  194.    {
  195.       this.setMenuOver(mc);
  196.    }
  197.    function menuOut(mc)
  198.    {
  199.    }
  200.    function menuPress(mc)
  201.    {
  202.    }
  203.    function menuRelease(mc)
  204.    {
  205.       this.dispatchEvent({type:"selection",target:mc,button_type:mc.type,lastOwner:this});
  206.    }
  207.    function init()
  208.    {
  209.       super.init();
  210.       if(com.argosy.ui.PopMenu.normal_style == undefined)
  211.       {
  212.          com.argosy.ui.PopMenu.normal_style = new TextField.StyleSheet();
  213.          com.argosy.ui.PopMenu.normal_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#000000",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  214.          com.argosy.ui.PopMenu.over_style = new TextField.StyleSheet();
  215.          com.argosy.ui.PopMenu.over_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#FFFFFF",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  216.          com.argosy.ui.PopMenu.selected_style = new TextField.StyleSheet();
  217.          com.argosy.ui.PopMenu.selected_style.setStyle("p",{fontFamily:"Frutiger Bold",fontSize:"12",color:"#FFFFFF",textAlign:"center",textDecoration:"none",kerning:"true",letterSpacing:"0"});
  218.       }
  219.       this.show(false);
  220.    }
  221.    function createChildren()
  222.    {
  223.       this.bg = this.createEmptyMovieClip("bg",1);
  224.       this.drop_shadow = new flash.filters.DropShadowFilter(5,45,0,0.8,10,10,1,3);
  225.    }
  226.    function layout()
  227.    {
  228.       this.bg.clear();
  229.       this.bg.lineStyle(0,13421772,100);
  230.       this.bg.beginFill(16777215,100);
  231.       this.bg.lineTo(this.width,0);
  232.       this.bg.lineTo(this.width,this.height);
  233.       this.bg.lineTo(0,this.height);
  234.       this.bg.lineTo(0,0);
  235.       this.bg.endFill();
  236.    }
  237. }
  238.