home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 90 / PIWD90.iso / mac / contents / flash / tutorial_files / Pages60-64 / ZoomMenu_MX.swf / scripts / sectionViewer.as next >
Text File  |  2003-12-18  |  3KB  |  83 lines

  1. function SectionViewer()
  2. {
  3.    var _loc2_ = this;
  4.    _loc2_.sections = {};
  5.    _loc2_.width = _loc2_._width;
  6.    _loc2_.createEmptyMovieClip("sectionHolder",_loc2_.backgroundClips.length);
  7.    _loc2_.clips = [];
  8.    var _loc1_ = 0;
  9.    while(_loc1_ < _loc2_.backgroundClips.length)
  10.    {
  11.       _loc2_.clips.push(_loc2_.attachMovie(_loc2_.backgroundClips[_loc1_],_loc2_.backgroundClips[_loc1_],_loc1_));
  12.       _loc1_ = _loc1_ + 1;
  13.    }
  14.    _loc2_.clipNum = 0;
  15. }
  16. var p = SectionViewer.prototype = new MovieClip();
  17. p.findSectionIndex = function(nm)
  18. {
  19.    var _loc1_ = this;
  20.    var _loc2_ = nm;
  21.    for(var _loc3_ in _loc1_.sectionOrder)
  22.    {
  23.       if(_loc1_.sectionOrder[_loc3_] == _loc2_)
  24.       {
  25.          return _loc3_;
  26.       }
  27.    }
  28. };
  29. p.loadSection = function(sectionName, sectionLink)
  30. {
  31.    var _loc1_ = this;
  32.    var _loc3_ = sectionName;
  33.    var _loc2_ = _loc1_.sectionHolder.attachMovie(sectionLink,_loc3_,_loc1_.clipNum++);
  34.    _loc1_.sections[_loc3_] = _loc2_;
  35.    _loc2_._x = _loc1_.width * _loc1_.findSectionIndex(_loc3_);
  36. };
  37. p.zoomSections = function()
  38. {
  39.    var _loc1_ = this;
  40.    var _loc3_ = _loc1_.sectionHolder;
  41.    _loc3_._xscale = _loc3_._yscale -= (_loc3_._xscale - _loc1_.endScale) / _loc1_.zoomRate;
  42.    _loc3_._x -= (_loc3_._x - _loc1_.endX) / _loc1_.zoomRate;
  43.    _loc3_._y -= (_loc3_._y - _loc1_.endY) / _loc1_.zoomRate;
  44.    if(Math.abs(_loc3_._x - _loc1_.endX) < 1 && _loc1_.endY - _loc3_._y < 1 && _loc3_._xscale - 100 < 1)
  45.    {
  46.       clearInterval(_loc1_.zoomInterval);
  47.       _loc3_._x = _loc1_.endX;
  48.       _loc3_._y = _loc1_.endY;
  49.       _loc3_._xscale = _loc3_._yscale = _loc1_.endScale;
  50.    }
  51.    for(var i in _loc1_.clips)
  52.    {
  53.       var _loc2_ = _loc1_.clips[i];
  54.       var adj = (Number(i) + 1) * 0.1;
  55.       _loc2_._xscale = _loc2_._yscale = 100 + (_loc3_._xscale - 100) * adj;
  56.       _loc2_._x = _loc3_._x / (_loc3_._xscale / 100) / (_loc1_.sectionOrder.length * _loc1_.width) * (_loc2_._width - _loc1_.width);
  57.       _loc2_._y = _loc3_._y * adj;
  58.    }
  59.    updateAfterEvent();
  60. };
  61. p.zoomToDetail = function(section)
  62. {
  63.    var _loc1_ = this;
  64.    var _loc3_ = _loc1_.sections[section].detail;
  65.    var _loc2_ = _loc1_.width / _loc3_._width;
  66.    _loc1_.endX = ((- _loc1_.width) * _loc1_.findSectionIndex(section) - _loc3_._x) * _loc2_;
  67.    _loc1_.endY = (- _loc3_._y) * _loc2_;
  68.    _loc1_.endScale = _loc2_ * 100;
  69.    clearInterval(_loc1_.zoomInterval);
  70.    _loc1_.zoomInterval = setInterval(_loc1_,"zoomSections",40);
  71. };
  72. p.zoomToSection = function(section)
  73. {
  74.    var _loc1_ = this;
  75.    _loc1_.endX = (- _loc1_.width) * _loc1_.findSectionIndex(section);
  76.    _loc1_.endY = 0;
  77.    _loc1_.endScale = 100;
  78.    clearInterval(_loc1_.zoomInterval);
  79.    _loc1_.zoomInterval = setInterval(_loc1_,"zoomSections",40);
  80. };
  81. Object.registerClass("sectionViewer",SectionViewer);
  82. delete p;
  83.