home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Internet Web Designer 90
/
PIWD90.iso
/
pc
/
contents
/
flash
/
tutorial_files
/
Pages60-64
/
ZoomMenu_MX.swf
/
scripts
/
sectionViewer.as
next >
Wrap
Text File
|
2003-01-01
|
3KB
|
83 lines
function SectionViewer()
{
var _loc2_ = this;
_loc2_.sections = {};
_loc2_.width = _loc2_._width;
_loc2_.createEmptyMovieClip("sectionHolder",_loc2_.backgroundClips.length);
_loc2_.clips = [];
var _loc1_ = 0;
while(_loc1_ < _loc2_.backgroundClips.length)
{
_loc2_.clips.push(_loc2_.attachMovie(_loc2_.backgroundClips[_loc1_],_loc2_.backgroundClips[_loc1_],_loc1_));
_loc1_ = _loc1_ + 1;
}
_loc2_.clipNum = 0;
}
var p = SectionViewer.prototype = new MovieClip();
p.findSectionIndex = function(nm)
{
var _loc1_ = this;
var _loc2_ = nm;
for(var _loc3_ in _loc1_.sectionOrder)
{
if(_loc1_.sectionOrder[_loc3_] == _loc2_)
{
return _loc3_;
}
}
};
p.loadSection = function(sectionName, sectionLink)
{
var _loc1_ = this;
var _loc3_ = sectionName;
var _loc2_ = _loc1_.sectionHolder.attachMovie(sectionLink,_loc3_,_loc1_.clipNum++);
_loc1_.sections[_loc3_] = _loc2_;
_loc2_._x = _loc1_.width * _loc1_.findSectionIndex(_loc3_);
};
p.zoomSections = function()
{
var _loc1_ = this;
var _loc3_ = _loc1_.sectionHolder;
_loc3_._xscale = _loc3_._yscale -= (_loc3_._xscale - _loc1_.endScale) / _loc1_.zoomRate;
_loc3_._x -= (_loc3_._x - _loc1_.endX) / _loc1_.zoomRate;
_loc3_._y -= (_loc3_._y - _loc1_.endY) / _loc1_.zoomRate;
if(Math.abs(_loc3_._x - _loc1_.endX) < 1 && _loc1_.endY - _loc3_._y < 1 && _loc3_._xscale - 100 < 1)
{
clearInterval(_loc1_.zoomInterval);
_loc3_._x = _loc1_.endX;
_loc3_._y = _loc1_.endY;
_loc3_._xscale = _loc3_._yscale = _loc1_.endScale;
}
for(var i in _loc1_.clips)
{
var _loc2_ = _loc1_.clips[i];
var adj = (Number(i) + 1) * 0.1;
_loc2_._xscale = _loc2_._yscale = 100 + (_loc3_._xscale - 100) * adj;
_loc2_._x = _loc3_._x / (_loc3_._xscale / 100) / (_loc1_.sectionOrder.length * _loc1_.width) * (_loc2_._width - _loc1_.width);
_loc2_._y = _loc3_._y * adj;
}
updateAfterEvent();
};
p.zoomToDetail = function(section)
{
var _loc1_ = this;
var _loc3_ = _loc1_.sections[section].detail;
var _loc2_ = _loc1_.width / _loc3_._width;
_loc1_.endX = ((- _loc1_.width) * _loc1_.findSectionIndex(section) - _loc3_._x) * _loc2_;
_loc1_.endY = (- _loc3_._y) * _loc2_;
_loc1_.endScale = _loc2_ * 100;
clearInterval(_loc1_.zoomInterval);
_loc1_.zoomInterval = setInterval(_loc1_,"zoomSections",40);
};
p.zoomToSection = function(section)
{
var _loc1_ = this;
_loc1_.endX = (- _loc1_.width) * _loc1_.findSectionIndex(section);
_loc1_.endY = 0;
_loc1_.endScale = 100;
clearInterval(_loc1_.zoomInterval);
_loc1_.zoomInterval = setInterval(_loc1_,"zoomSections",40);
};
Object.registerClass("sectionViewer",SectionViewer);
delete p;