home *** CD-ROM | disk | FTP | other *** search
/ Sears Catalog 2006 Spring/Summer (French Canadian) / SearsCanada-AutomneEte2006-FrenchVersion-WinMac.bin / fr / howtohintread.swf / scripts / ultimateScroller.as < prev   
Text File  |  2005-11-15  |  39KB  |  1,324 lines

  1. function ultimateScrollerClass()
  2. {
  3.    this.initialize();
  4. }
  5. ultimateScrollerClass.prototype = new MovieClip();
  6. ultimateScrollerClass.prototype.scrollUp = function()
  7. {
  8.    if(this.enabled == false)
  9.    {
  10.       return undefined;
  11.    }
  12.    if(this.c_horizontal)
  13.    {
  14.       if(this.targetClip._x < this.scrollBottom)
  15.       {
  16.          var _loc4_ = this.targetClip._x + this.scrollAmount >= this.scrollBottom ? this.scrollBottom : this.targetClip._x + this.scrollAmount;
  17.          var _loc2_ = (_loc4_ - this.scrollBottom) * 100 / (this.scrollBottom - this.scrollTop) * -1;
  18.          this.drag._y = Math.floor(this.dragTop - (this.dragTop - this.dragBottom) / 100 * _loc2_);
  19.          this.syncTargetPos();
  20.          false;
  21.          false;
  22.       }
  23.    }
  24.    else if(this.targetClip._y < this.scrollTop)
  25.    {
  26.       var _loc3_ = this.targetClip._y + this.scrollAmount >= this.scrollTop ? this.scrollTop : this.targetClip._y + this.scrollAmount;
  27.       _loc2_ = (_loc3_ - this.scrollTop) * 100 / (this.scrollTop - this.scrollBottom) * -1;
  28.       this.drag._y = Math.floor(this.dragTop - (this.dragTop - this.dragBottom) / 100 * _loc2_);
  29.       this.syncTargetPos();
  30.       false;
  31.       false;
  32.    }
  33. };
  34. ultimateScrollerClass.prototype.scrollDown = function()
  35. {
  36.    if(this.enabled == false)
  37.    {
  38.       return undefined;
  39.    }
  40.    if(this.c_horizontal == true)
  41.    {
  42.       if(this.targetClip._x > this.scrollTop)
  43.       {
  44.          var _loc4_ = this.targetClip._x - this.scrollAmount <= this.scrollTop ? this.scrollTop : this.targetClip._x - this.scrollAmount;
  45.          var _loc2_ = (_loc4_ - this.scrollBottom) * 100 / (this.scrollBottom - this.scrollTop) * -1;
  46.          this.drag._y = Math.ceil(this.dragTop - (this.dragTop - this.dragBottom) / 100 * _loc2_);
  47.          this.syncTargetPos();
  48.          false;
  49.          false;
  50.       }
  51.    }
  52.    else if(this.targetClip._y > this.scrollBottom)
  53.    {
  54.       var _loc3_ = this.targetClip._y - this.scrollAmount <= this.scrollBottom ? this.scrollBottom : this.targetClip._y - this.scrollAmount;
  55.       _loc2_ = (_loc3_ - this.scrollTop) * 100 / (this.scrollTop - this.scrollBottom) * -1;
  56.       this.drag._y = Math.ceil(this.dragTop - (this.dragTop - this.dragBottom) / 100 * _loc2_);
  57.       this.syncTargetPos();
  58.       false;
  59.       false;
  60.    }
  61. };
  62. ultimateScrollerClass.prototype.pageUp = function()
  63. {
  64.    var _loc2_ = this.c_scrollAmount;
  65.    this.c_scrollAmount = int(this.h);
  66.    this.scrollUp();
  67.    this.c_scrollAmount = _loc2_;
  68.    false;
  69. };
  70. ultimateScrollerClass.prototype.pageDown = function()
  71. {
  72.    var _loc2_ = this.c_scrollAmount;
  73.    this.c_scrollAmount = int(this.h);
  74.    this.scrollDown();
  75.    this.c_scrollAmount = _loc2_;
  76.    false;
  77. };
  78. ultimateScrollerClass.prototype.scrollToTop = function()
  79. {
  80.    if(this.enabled == false)
  81.    {
  82.       return undefined;
  83.    }
  84.    this.drag._y = this.dragTop;
  85.    this.syncTargetPos();
  86. };
  87. ultimateScrollerClass.prototype.scrollToBottom = function()
  88. {
  89.    if(this.enabled == false)
  90.    {
  91.       return undefined;
  92.    }
  93.    this.drag._y = this.dragBottom;
  94.    this.syncTargetPos();
  95. };
  96. ultimateScrollerClass.prototype.getScrollPosition = function()
  97. {
  98.    return this.drag._y;
  99. };
  100. ultimateScrollerClass.prototype.setScrollPosition = function(scrollPos)
  101. {
  102.    this.drag._y = scrollPos;
  103. };
  104. ultimateScrollerClass.prototype.setDragHeight = function(usrHeight)
  105. {
  106.    this.c_dragHeight = usrHeight;
  107.    if(usrHeight > this.track_mc._height - 48)
  108.    {
  109.       usrHeight = this.track_mc._height - 48;
  110.    }
  111.    else if(usrHeight < 2)
  112.    {
  113.       usrHeight = 2;
  114.    }
  115.    this.dragHeight = usrHeight;
  116.    var btnDrag = this.attachMovie("ultimateScroller_drag","drag",5,{_x:0,_y:16,w:this.c_scrollWidth,h:this.dragHeight});
  117.    btnDrag.useHandCursor = false;
  118.    this.dragTop = 16;
  119.    this.dragBottom = this.h - 16 - this.dragHeight;
  120.    if(this.scrollTo != null)
  121.    {
  122.       btnDrag._y = this.scrollTo <= this.dragBottom ? this.scrollTo : this.dragBottom;
  123.       var _loc3_ = this.c_easing;
  124.       this.c_easing = "none";
  125.       this.syncTargetPos();
  126.       this.c_easing = _loc3_;
  127.       false;
  128.    }
  129.    btnDrag.onMouseDown = function()
  130.    {
  131.       if(this._parent.enabled == false)
  132.       {
  133.          return undefined;
  134.       }
  135.       if(btnDrag.hitTest(_level0._xmouse,_level0._ymouse))
  136.       {
  137.          btnDrag.startDrag(false,0,this._parent.dragTop,0,this._parent.dragBottom);
  138.          this._parent.dragging = true;
  139.          updateAfterEvent();
  140.       }
  141.    };
  142.    btnDrag.onMouseUp = function()
  143.    {
  144.       btnDrag.stopDrag();
  145.       this._parent.dragging = false;
  146.       updateAfterEvent();
  147.    };
  148.    if(!this.c_dragVisible)
  149.    {
  150.       this.drag._visible = false;
  151.    }
  152. };
  153. ultimateScrollerClass.prototype.initialize = function()
  154. {
  155.    this.setDefaults();
  156.    this.enabled = false;
  157.    if(this.c_horizontal == true)
  158.    {
  159.       this._rotation = -90;
  160.       this._xscale = -100;
  161.       this._y = int(this._y + 16);
  162.       if(this.size == null)
  163.       {
  164.          this.setSize(this._width);
  165.       }
  166.       else
  167.       {
  168.          this.setSize(this.size);
  169.       }
  170.    }
  171.    else
  172.    {
  173.       this._rotation = 0;
  174.       this._xscale = 100;
  175.       if(this.size == null)
  176.       {
  177.          this.setSize(this._height);
  178.       }
  179.       else
  180.       {
  181.          this.setSize(this.size);
  182.       }
  183.    }
  184.    if(this._targetInstanceName.length > 0)
  185.    {
  186.       var _loc2_ = this._parent[this._targetInstanceName];
  187.       this.initX = _loc2_._x;
  188.       this.initY = _loc2_._y;
  189.       this.initW = _loc2_._width;
  190.       this.initH = _loc2_._height;
  191.       this.setTarget(_loc2_);
  192.       false;
  193.    }
  194.    else
  195.    {
  196.       this.setEnabled(false);
  197.    }
  198. };
  199. ultimateScrollerClass.prototype.setDefaults = function()
  200. {
  201.    if(this.c_horizontal == null)
  202.    {
  203.       if(this.horizontal == null)
  204.       {
  205.          this.c_horizontal = false;
  206.       }
  207.       else
  208.       {
  209.          this.c_horizontal = Boolean(this.horizontal);
  210.          delete this.horizontal;
  211.       }
  212.    }
  213.    if(this.c_buffer == null)
  214.    {
  215.       if(this.buffer == null)
  216.       {
  217.          this.c_buffer = 10;
  218.       }
  219.       else
  220.       {
  221.          this.c_buffer = int(this.buffer);
  222.          delete this.buffer;
  223.       }
  224.    }
  225.    if(this.c_scrollAmount == null)
  226.    {
  227.       if(this.scrollAmount == null)
  228.       {
  229.          this.c_scrollAmount = 40;
  230.       }
  231.       else
  232.       {
  233.          this.c_scrollAmount = int(this.scrollAmount);
  234.          delete this.scrollAmount;
  235.       }
  236.    }
  237.    if(this.c_easing == null)
  238.    {
  239.       if(this.easing == null)
  240.       {
  241.          this.c_easing = "none";
  242.       }
  243.       else
  244.       {
  245.          this.c_easing = this.easing;
  246.          delete this.easing;
  247.       }
  248.    }
  249.    if(this.c_useMask == null)
  250.    {
  251.       if(this.useMask == null)
  252.       {
  253.          this.c_useMask = false;
  254.       }
  255.       else
  256.       {
  257.          this.c_useMask = Boolean(this.useMask);
  258.          delete this.useMask;
  259.       }
  260.    }
  261.    if(this.c_dragVisible == null)
  262.    {
  263.       if(this.dragVisible == null)
  264.       {
  265.          this.c_dragVisible = true;
  266.       }
  267.       else
  268.       {
  269.          this.c_dragVisible = Boolean(this.dragVisible);
  270.          delete this.dragVisible;
  271.       }
  272.    }
  273.    if(this.c_dragAuto == null)
  274.    {
  275.       if(this.dragHeightAuto == null)
  276.       {
  277.          this.c_dragAuto = true;
  278.       }
  279.       else
  280.       {
  281.          this.c_dragAuto = Boolean(this.dragHeightAuto);
  282.          delete this.dragHeightAuto;
  283.       }
  284.    }
  285.    if(this.c_scrollTrackVisible == null)
  286.    {
  287.       if(this.scrollTrackVisible == null)
  288.       {
  289.          this.c_scrollTrackVisible = true;
  290.       }
  291.       else
  292.       {
  293.          this.c_scrollTrackVisible = Boolean(this.scrollTrackVisible);
  294.          delete this.scrollTrackVisible;
  295.       }
  296.    }
  297.    if(this.c_buttonsVisible == null)
  298.    {
  299.       if(this.buttonsVisible == null)
  300.       {
  301.          this.c_buttonsVisible = true;
  302.       }
  303.       else
  304.       {
  305.          this.c_buttonsVisible = Boolean(this.buttonsVisible);
  306.          delete this.buttonsVisible;
  307.       }
  308.    }
  309.    if(this.c_arrowsVisible == null)
  310.    {
  311.       if(this.arrowsVisible == null)
  312.       {
  313.          this.c_arrowsVisible = true;
  314.