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

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