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 >
Wrap
Text File
|
2003-12-18
|
3KB
|
74 lines
function SectionViewer()
{
this.sections = {};
this.width = this._width;
this.createEmptyMovieClip("sectionHolder",this.backgroundClips.length);
this.clips = [];
var _loc2_ = 0;
while(_loc2_ < this.backgroundClips.length)
{
this.clips.push(this.attachMovie(this.backgroundClips[_loc2_],this.backgroundClips[_loc2_],_loc2_));
_loc2_ = _loc2_ + 1;
}
}
var p = SectionViewer.prototype = new MovieClip();
p.findSectionIndex = function(nm)
{
for(var _loc3_ in this.sectionOrder)
{
if(this.sectionOrder[_loc3_] == nm)
{
return _loc3_;
}
}
};
p.loadSection = function(sectionName, sectionLink)
{
var _loc2_ = this.sectionHolder.attachMovie(sectionLink,sectionName,this.sectionHolder.getNextHighestDepth());
this.sections[sectionName] = _loc2_;
_loc2_._x = this.width * this.findSectionIndex(sectionName);
};
p.zoomSections = function()
{
var _loc3_ = this.sectionHolder;
_loc3_._xscale = _loc3_._yscale -= (_loc3_._xscale - this.endScale) / this.zoomRate;
_loc3_._x -= (_loc3_._x - this.endX) / this.zoomRate;
_loc3_._y -= (_loc3_._y - this.endY) / this.zoomRate;
if(Math.abs(_loc3_._x - this.endX) < 1 && this.endY - _loc3_._y < 1 && _loc3_._xscale - 100 < 1)
{
clearInterval(this.zoomInterval);
_loc3_._x = this.endX;
_loc3_._y = this.endY;
_loc3_._xscale = _loc3_._yscale = this.endScale;
}
for(var _loc5_ in this.clips)
{
var _loc2_ = this.clips[_loc5_];
var _loc4_ = (Number(_loc5_) + 1) * 0.1;
_loc2_._xscale = _loc2_._yscale = 100 + (_loc3_._xscale - 100) * _loc4_;
_loc2_._x = _loc3_._x / (_loc3_._xscale / 100) / (this.sectionOrder.length * this.width) * (_loc2_._width - this.width);
_loc2_._y = _loc3_._y * _loc4_;
}
updateAfterEvent();
};
p.zoomToDetail = function(section)
{
var _loc3_ = this.sections[section].detail;
var _loc2_ = this.width / _loc3_._width;
this.endX = ((- this.width) * this.findSectionIndex(section) - _loc3_._x) * _loc2_;
this.endY = (- _loc3_._y) * _loc2_;
this.endScale = _loc2_ * 100;
clearInterval(this.zoomInterval);
this.zoomInterval = setInterval(this,"zoomSections",40);
};
p.zoomToSection = function(section)
{
this.endX = (- this.width) * this.findSectionIndex(section);
this.endY = 0;
this.endScale = 100;
clearInterval(this.zoomInterval);
this.zoomInterval = setInterval(this,"zoomSections",40);
};
Object.registerClass("sectionViewer",SectionViewer);
delete p;