ACTIONSCRIPT   65
dock
Guest on 24th August 2022 04:57:17 AM


  1. class Dock extends MovieClip
  2. {
  3.     var onEnterFrame, layout, icon_min, icon_max, icon_spacing, span, amplitude, ratio, items, width, createEmptyMovieClip, icon_size, _rotation, _parent, _name, ymouse, xmouse, tray_mc, _xmouse, _ymouse;
  4.     function Dock()
  5.     {
  6.         super();
  7.         this.setParameters();
  8.         this.setLayout();
  9.         this.createIcons();
  10.         this.createTray();
  11.         onEnterFrame = monitorDock;
  12.     } // End of the function
  13.     function setParameters()
  14.     {
  15.         layout = layout ? (layout) : ("bottom");
  16.         icon_min = icon_min ? (icon_min) : (32);
  17.         icon_max = icon_max ? (icon_max) : (96);
  18.         icon_spacing = icon_spacing ? (icon_spacing) : (2);
  19.         span = span ? (span) : (this.getSpan());
  20.         amplitude = amplitude ? (amplitude) : (this.getAmplitude());
  21.         ratio = 1.570796E+000 / span;
  22.     } // End of the function
  23.     function getSpan()
  24.     {
  25.         return ((icon_min - 16) * 180 / 80 + 60);
  26.     } // End of the function
  27.     function getAmplitude()
  28.     {
  29.         return (2 * (icon_max - icon_min + icon_spacing));
  30.     } // End of the function
  31.     function createIcons()
  32.     {
  33.         var _loc2;
  34.         var _loc4;
  35.         scale = 0;
  36.         width = (items.length - 1) * icon_spacing + items.length * icon_min;
  37.         var _loc3 = (icon_min - width) / 2;
  38.         for (var _loc2 = 0; _loc2 < items.length; ++_loc2)
  39.         {
  40.             this.createEmptyMovieClip(String(_loc2), _loc2 + 10).attachMovie(items[_loc2].id, "_mc", 1);
  41.             this[_loc2]._mc._y = -icon_size / 2;
  42.             this[_loc2]._mc._rotation = -_rotation;
  43.             this[_loc2]._x = this[_loc2].x = _loc3 + _loc2 * (icon_min + icon_spacing) + icon_spacing / 2;
  44.             this[_loc2]._y = -icon_spacing;
  45.             this[_loc2].onRelease = launchIcon;
  46.             this[_loc2].useHandCursor = false;
  47.         } // end of for
  48.     } // End of the function
  49.     function launchIcon()
  50.     {
  51.         _parent.callback(_parent.items[_name].label);
  52.     } // End of the function
  53.     function createTray()
  54.     {
  55.         var _loc4 = icon_min + 2 * icon_spacing;
  56.         var _loc3 = width + 2 * icon_spacing;
  57.         var _loc2 = this.createEmptyMovieClip("tray_mc", 1);
  58.         _loc2.lineStyle(0, 13421772, 80);
  59.         _loc2.beginFill(15263976, 50);
  60.         _loc2.lineTo(0, -_loc4);
  61.         _loc2.lineTo(_loc3, -_loc4);
  62.         _loc2.lineTo(_loc3, 0);
  63.         _loc2.lineTo(0, 0);
  64.         _loc2.endFill();
  65.     } // End of the function
  66.     function setLayout()
  67.     {
  68.         switch (layout)
  69.         {
  70.             case "left":
  71.             {
  72.                 _rotation = 90;
  73.                 break;
  74.             }
  75.             case "top":
  76.             {
  77.                 _rotation = 180;
  78.                 break;
  79.             }
  80.             case "right":
  81.             {
  82.                 _rotation = 270;
  83.                 break;
  84.             }
  85.             default:
  86.             {
  87.                 _rotation = Number(layout);
  88.             }
  89.         } // End of switch
  90.     } // End of the function
  91.     function checkBoundary()
  92.     {
  93.         var _loc2 = 4 * scale;
  94.         return (ymouse < 0 && ymouse > -2 * icon_spacing - icon_min + (icon_min - icon_max) * scale && xmouse > this[0]._x - this[0]._width / 2 - icon_spacing - _loc2 && xmouse < this[items.length - 1]._x + this[items.length - 1]._width / 2 + icon_spacing + _loc2);
  95.     } // End of the function
  96.     function updateTray()
  97.     {
  98.         var _loc2;
  99.         var _loc3;
  100.         _loc2 = this[0]._x - this[0]._width / 2 - icon_spacing;
  101.         _loc3 = this[items.length - 1]._x + this[items.length - 1]._width / 2 + icon_spacing;
  102.         tray_mc._x = _loc2;
  103.         tray_mc._width = _loc3 - _loc2;
  104.     } // End of the function
  105.     function monitorDock()
  106.     {
  107.         var _loc2;
  108.         var _loc5;
  109.         var _loc3;
  110.         var _loc4;
  111.         if (xmouse == _xmouse && ymouse == _ymouse && (scale <= 1.000000E-002 || scale >= 9.900000E-001))
  112.         {
  113.             return (false);
  114.         } // end if
  115.         xmouse = _xmouse;
  116.         ymouse = _ymouse;
  117.         trend = trend == 0 ? (this.checkBoundary() ? (2.500000E-001) : (-2.500000E-001)) : (trend);
  118.         scale = scale + trend;
  119.         if (scale < 2.000000E-002 || scale > 9.800000E-001)
  120.         {
  121.             trend = 0;
  122.         } // end if
  123.         scale = Math.min(1, Math.max(0, scale));
  124.         for (var _loc2 = 0; _loc2 < items.length; ++_loc2)
  125.         {
  126.             _loc3 = this[_loc2].x - xmouse;
  127.             _loc3 = Math.min(Math.max(_loc3, -span), span);
  128.             _loc4 = icon_min + (icon_max - icon_min) * Math.cos(_loc3 * ratio) * (Math.abs(_loc3) > span ? (0) : (1)) * scale;
  129.             this[_loc2]._x = this[_loc2].x + scale * amplitude * Math.sin(_loc3 * ratio);
  130.             this[_loc2]._xscale = this[_loc2]._yscale = 100 * _loc4 / icon_size;
  131.         } // end of for
  132.         this.updateTray();
  133.         return (true);
  134.     } // End of the function
  135.     var scale = Number.NEGATIVE_INFINITY;
  136.     var trend = 0;
  137. } // End of Class

Raw Paste

Login or Register to edit or fork this paste. It's free.