home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FCE Gold Plus
/
GOLD.iso
/
pc
/
main.swf
/
scripts
/
__Packages
/
Friends_navigation.as
< prev
next >
Wrap
Text File
|
2007-11-02
|
25KB
|
834 lines
class Friends_navigation
{
var interval = 50;
var fileClicked = false;
var bDrawBar = false;
var arrSectionMCs = [{linkage:"ExternalNavigationElementLevel0",size:{w:108,h:18}},{linkage:"ExternalNavigationElementLevel1",size:{w:108,h:18}},{linkage:"ExternalNavigationElementEnd",size:{w:108,h:700},draw:true,level:3}];
function Friends_navigation(navigation_mc)
{
this.navigation_mc = navigation_mc;
this.init();
this.initFileBtn(navigation_mc._parent.homeBtn,null,true);
}
function removeNavigation()
{
this.navigation_mc.createEmptyMovieClip("base_mc",1);
this.arrTempNavigation = [];
this.count = 0;
this.navigationHeight = 0;
this.base_mc = this.navigation_mc.base_mc;
this.createEndNode();
}
function disable()
{
this.base_mc.onRelease = null;
this.base_mc.useHandCursor = false;
}
function enable()
{
delete this.base_mc.onRelease;
}
function init()
{
this.showNavigation(false);
this.levelOpen = 0;
this.lastFileClicked = [];
this.hideDummys();
}
function testMatch(arr1, arr2)
{
var _loc3_ = 0;
var _loc1_ = 0;
while(_loc1_ < arr2.length)
{
if(arr1[_loc1_] == arr2[_loc1_])
{
_loc3_ = _loc3_ + 1;
}
_loc1_ = _loc1_ + 1;
}
if(_loc3_ == arr2.length)
{
return true;
}
return false;
}
function createEndNode()
{
var _loc4_ = this.arrSectionMCs[this.arrSectionMCs.length - 1];
var _loc3_ = _loc4_.linkage;
var _loc2_ = this.base_mc.attachMovie(_loc3_,"section" + this.count + "_mc",this.count);
_loc2_.x += 2;
return _loc2_;
}
function createNodeMC(buttObj)
{
var _loc5_ = this.arrSectionMCs[buttObj.nodePath.length - 1];
var _loc4_ = _loc5_.linkage;
if(buttObj.bFolder && buttObj.nodePath.length == 1)
{
_loc4_ += "b";
}
else if(!buttObj.activitySectionFile)
{
if(!buttObj.referenceFile)
{
}
}
var _loc7_ = _loc5_.size;
var _loc3_ = this.base_mc.attachMovie(_loc4_,"section" + this.count + "_mc",this.count,{label:buttObj.label});
_loc3_.x += 2;
_loc3_.txtObj.embedFonts = true;
return _loc3_;
}
function checkDrawNodePath(mc, arrDrawRef)
{
var _loc4_ = this.arrTempNavigation[this.arrDrawNavigation[arrDrawRef]].nodePath.slice();
if((this.arrTempNavigation[this.arrDrawNavigation[arrDrawRef]].nodePath.length > this.arrTempNavigation[this.arrDrawNavigation[arrDrawRef + 1]].nodePath.length || this.arrTempNavigation[this.arrDrawNavigation[arrDrawRef + 1]].nodePath.length == undefined) && this.arrTempNavigation[this.arrDrawNavigation[arrDrawRef]].nodePath.length != 1)
{
mc.isBase = true;
}
else
{
mc.isBase = false;
}
}
function drawNodeMC(arrDrawRef, bEnd)
{
var _loc3_ = this.arrDrawNavigation[arrDrawRef];
if(!bEnd)
{
var _loc2_ = this.createNodeMC(this.arrTempNavigation[_loc3_]);
var _loc6_ = undefined;
_loc2_._y = this.navigationHeight;
this.checkDrawNodePath(_loc2_,arrDrawRef);
if(_loc2_.isBase)
{
this.navigationHeight += 3;
}
trace("arrTempNavigation[id].bFolder" + this.arrTempNavigation[_loc3_].bFolder);
if(this.arrTempNavigation[_loc3_].bFolder)
{
this.initFolderBtn(_loc2_,this.arrTempNavigation[_loc3_]);
if(this.testMatch(this.lastFolderClicked,this.arrTempNavigation[_loc3_].nodePath))
{
_loc2_.isOpen = true;
_loc2_.arrowMC._rotation = 90;
this.changeBtnState(_loc2_,"_active");
}
else
{
_loc2_.isOpen = false;
_loc2_.arrowMC._rotation = 0;
this.changeBtnState(_loc2_,"_start");
}
}
else
{
_loc2_.arrowMC._visible = false;
this.initFileBtn(_loc2_,this.arrTempNavigation[_loc3_]);
if(_loc2_.isBase)
{
if(this.testMatch(this.lastFileClicked,this.arrTempNavigation[_loc3_].nodePath))
{
_loc2_.isOpen = true;
this.changeBtnState(_loc2_,"_baseOver");
}
else
{
_loc2_.isOpen = false;
this.changeBtnState(_loc2_,"_base");
}
}
else if(this.testMatch(this.lastFileClicked,this.arrTempNavigation[_loc3_].nodePath))
{
trace("hhheeeellllooo asaf");
_loc2_.isOpen = true;
this.changeBtnState(_loc2_,"_rollover");
}
else
{
_loc2_.isOpen = false;
this.changeBtnState(_loc2_,"_start");
}
}
if(this.arrTempNavigation[_loc3_].nodePath.length == 1)
{
this.navigationHeight += this.arrTempNavigation[_loc3_].size.h - 2;
}
else
{
this.navigationHeight += this.arrTempNavigation[_loc3_].size.h - 4;
}
}
}
function updateDrawNavigation()
{
var _loc4_ = this.arrTempNavigation.length;
var _loc3_ = true;
var _loc2_ = 0;
while(_loc2_ < _loc4_ && _loc3_)
{
if(!this.arrTempNavigation[_loc2_].draw)
{
this.arrDrawNavigation.splice(_loc2_,0,_loc2_);
this.arrTempNavigation[_loc2_].draw = true;
this.setDrawStatesByNode(this.arrNavigation,this.arrTempNavigation[_loc2_].nodePath.slice(),true);
_loc3_ = false;
}
_loc2_ = _loc2_ + 1;
}
}
function setDrawStatesByNode(arrNav, nodePath, state)
{
if(nodePath.length == 1)
{
arrNav[nodePath[0]].draw = state;
}
else
{
var _loc3_ = nodePath[0];
nodePath.shift();
this.setDrawStatesByNode(arrNav[_loc3_].arrSubSections,nodePath,state);
}
}
function animateMenu()
{
var _loc3_ = this.arrDrawNavigation.length;
var _loc5_ = true;
this.levelOpen = 0;
this.count = 0;
this.navigationHeight = 5;
var _loc2_ = 0;
while(_loc2_ < _loc3_)
{
this.drawNodeMC(_loc2_,false);
this.count = this.count + 1;
_loc2_ = _loc2_ + 1;
}
this.drawNodeMC(null,true);
this.updateDrawNavigation();
var _loc4_ = this;
var _loc6_ = undefined;
if(_loc3_ >= this.arrTempNavigation.length)
{
clearInterval(this.drawInterval);
}
}
function drawMenu(bDraw)
{
var _loc3_ = this.arrTempNavigation.length;
this.maxLevel = 1;
this.arrDrawNavigation = [];
var _loc2_ = 0;
while(_loc2_ < _loc3_)
{
if(this.arrTempNavigation[_loc2_].nodePath.length - 1 > this.maxLevel)
{
this.maxLevel = this.arrTempNavigation[_loc2_].nodePath.length - 1;
}
_loc2_ = _loc2_ + 1;
}
_loc2_ = 0;
while(_loc2_ < _loc3_)
{
if(this.arrTempNavigation[_loc2_].draw)
{
this.arrDrawNavigation.push(_loc2_);
}
else if(this.arrTempNavigation[_loc2_].nodePath.length - 1 != this.maxLevel)
{
this.arrTempNavigation[_loc2_].draw = true;
this.arrDrawNavigation.push(_loc2_);
}
else if(this.arrTempNavigation[_loc2_].nodePath.length - 1 <= this.levelOpen)
{
this.arrTempNavigation[_loc2_].draw = true;
this.arrDrawNavigation.push(_loc2_);
}
_loc2_ = _loc2_ + 1;
}
if(bDraw)
{
this.animateMenu();
clearInterval(this.drawInterval);
this.drawInterval = setInterval(this,"animateMenu",this.interval);
}
}
function createNavObject(elementArrNav)
{
var _loc3_ = {};
for(var _loc4_ in elementArrNav)
{
if(_loc4_ != "arrSubSections")
{
_loc3_[_loc4_] = elementArrNav[_loc4_];
}
}
_loc3_.size = this.arrSectionMCs[_loc3_.nodePath.length - 1].size;
_loc3_.draw = elementArrNav.draw;
return _loc3_;
}
function clearMenu()
{
this.resetMenu();
this.lastFolderClicked = [];
this.lastFileClicked = [];
this.buildMenu(this.arrNavigation,[]);
this.drawMenu(true);
}
function buildMenu(arrNav, navNodePath)
{
var _loc2_ = 0;
while(_loc2_ < arrNav.length)
{
this.arrTempNavigation[this.count++] = this.createNavObject(arrNav[_loc2_]);
if(navNodePath[0] == _loc2_)
{
navNodePath.shift();
var _loc5_ = arrNav[_loc2_].arrSubSections.length;
this.buildMenu(arrNav[_loc2_].arrSubSections,navNodePath);
}
_loc2_ = _loc2_ + 1;
}
}
function resetMenu()
{
this.navigation_mc.createEmptyMovieClip("base_mc",1);
this.arrTempNavigation = [];
this.count = 0;
this.navigationHeight = 0;
this.base_mc = this.navigation_mc.base_mc;
}
function createMenu(bDraw)
{
var _loc2_ = undefined;
this.resetMenu();
if(this.reopenNode.length)
{
_loc2_ = this.lastFolderClicked.slice();
}
else if(this.fileClicked)
{
_loc2_ = this.lastFileClicked.slice();
}
else
{
_loc2_ = this.lastFolderClicked.slice();
}
this.buildMenu(this.arrNavigation,_loc2_);
this.drawMenu(bDraw);
}
function initialDisplay()
{
this.createMenu(true);
this.reopenNode = [];
this.showNavigation(true);
}
function initFolderBtn(btn, nodeData)
{
var manager = this;
btn.nodeData = nodeData;
btn.onRelease = function()
{
_root.secondPage.unitPicture.gotoAndStop(btn.nodeData.refNo);
manager.onFolderClicked(this,true);
};
btn.onRollOver = function()
{
manager.changeBtnRollOver(this);
_root.firstPage.firstPagePicture.gotoAndStop(this.nodeData.refNo);
};
btn.onRollOut = function()
{
manager.changeBtnRollOut(this);
};
btn.onReleaseOutside = function()
{
manager.changeBtnRollOut(this);
};
}
function initFileBtn(btn, nodeData, bHomeBtn)
{
var manager = this;
btn.nodeData = nodeData;
btn.state = "_start";
if(bHomeBtn == undefined)
{
btn.onRelease = function()
{
manager.onFileClicked(this,true);
};
}
else
{
btn.txtObj.embedFonts = true;
btn.label = "Main Menu";
btn._y = -1 + _root.header._height;
btn.onRelease = function()
{
manager.clearMenu();
_root.unitData.homeBtnPress();
};
}
btn.onRollOver = function()
{
manager.changeBtnRollOver(this);
};
btn.onRollOut = function()
{
manager.changeBtnRollOut(this);
};
btn.onReleaseOutside = function()
{
manager.changeBtnRollOut(this);
};
}
function changeBtnRollOut(btn)
{
if(btn.nodeData.bFolder && !btn.isOpen || !btn.nodeData.bFolder && !btn.isOpen)
{
if(btn.isBase)
{
btn.gotoAndStop("_base");
}
else
{
btn.gotoAndStop("_start");
}
btn.txtObj.embedFonts = true;
}
else if(btn.nodeData.bFolder && btn.isOpen)
{
btn.gotoAndStop("_active");
btn.txtObj.embedFonts = true;
}
}
function changeBtnRollOver(btn)
{
if(!(btn.nodeData.bFolder && btn.isOpen))
{
if(btn.isBase)
{
btn.gotoAndStop("_baseOver");
}
else
{
btn.gotoAndStop("_rollover");
}
btn.txtObj.embedFonts = true;
}
}
function changeBtnState(btn, state)
{
if(btn.nodeData.header != "green")
{
btn.gotoAndStop(state);
}
btn.txtObj.embedFonts = true;
btn.state = state;
}
function clearDrawState(arrNav, nodePath)
{
var _loc3_ = arrNav.length;
if(nodePath.length == 0)
{
var _loc2_ = 0;
while(_loc2_ < _loc3_)
{
arrNav[_loc2_].draw = false;
_loc2_ = _loc2_ + 1;
}
}
else
{
var _loc6_ = nodePath[0];
nodePath.shift();
this.clearDrawState(arrNav[_loc6_].arrSubSections,nodePath);
}
}
function onFileClicked(btnNode, bFromNavigation)
{
this.fileClicked = true;
var _loc4_ = btnNode.nodeData.nodePath.slice();
var _loc3_ = undefined;
if(_loc4_.length > 1)
{
_loc3_ = _loc4_.slice();
_loc3_.pop();
}
if(_loc3_ != undefined)
{
if(!this.testMatch(this.lastFolderClicked,_loc3_))
{
this.lastFolderClicked = _loc3_.slice();
this.clearDrawState(this.arrNavigation,_loc3_);
}
}
this.lastFileClicked = _loc4_.slice();
trace("lastFileClicked = " + this.lastFileClicked);
this.reopenNode = [];
if(_loc4_.length == 1)
{
this.lastFolderClicked = [];
}
_root.currId = btnNode.nodeData.unit;
trace("i am on file clicked in navigation");
_root.loadedFromNav = true;
if(btnNode.label != "iTest")
{
_root.onFileClicked(btnNode.nodeData);
}
else
{
_root.onFileClicked(btnNode.nodeData);
this.clearMenu();
_root.unitData.homeBtnPress();
}
this.createMenu(true);
}
function onFolderClicked(btnNode, bFromNavigation)
{
trace("folder clicked: " + this.lastFileClicked);
var _loc5_ = true;
var _loc4_ = btnNode.nodeData.nodePath.slice();
this.fileClicked = false;
if(_loc4_.length == 1 && this.lastFolderClicked[0] == _loc4_[0] && this.lastFileClicked.length != 0)
{
_loc5_ = false;
}
if(this.testMatch(this.lastFolderClicked,_loc4_) && bFromNavigation)
{
this.lastFolderClicked = _loc4_.slice();
if(_loc5_)
{
this.lastFolderClicked.pop();
}
}
else if(this.testMatch(this.reopenNode,_loc4_) && bFromNavigation)
{
this.lastFolderClicked = this.reopenNode.slice();
}
else
{
this.lastFolderClicked = _loc4_.slice();
}
if(_loc4_.length == 1)
{
this.reopenNode = [];
this.lastFileClicked = [];
if(this.arrNavigation[_loc4_[0]].label != "Activities")
{
_root.unitData.unitBtnPress(_loc4_[0]);
}
}
else if(_loc4_[0] == 0 && _loc4_.length == 2)
{
this.reopenNode = [];
this.lastFileClicked = [];
}
else if(_loc4_[0] == 0 && _loc4_.length == 3)
{
this.reopenNode = [];
this.lastFileClicked = [];
}
if(_loc4_[0] == this.reopenNode[0] && _loc4_.length == 1 && bFromNavigation)
{
this.clearDrawState(this.arrNavigation,this.reopenNode.slice());
}
else if(_loc5_)
{
this.clearDrawState(this.arrNavigation,_loc4_.slice());
}
else if(_loc4_[0] == 0 && _loc4_.length == 1)
{
var _loc3_ = 0;
while(_loc3_ < this.arrNavigation[0].arrSubSections.length)
{
this.arrNavigation[0].arrSubSections[_loc3_].draw = true;
_loc3_ = _loc3_ + 1;
}
}
this.createMenu(true);
}
function subBtnClicked(unit, subUnit, bDontCollapseNav)
{
var _loc3_ = {};
this.lastFileClicked = [];
this.reopenNode = [];
_loc3_.nodeData = this.createNavObject(this.arrNavigation[0]);
_loc3_.nodeData = this.createNavObject(this.arrNavigation[0].arrSubSections[unit].arrSubSections[subUnit]);
_loc3_.nodeData.nodePath = [0,unit,subUnit];
if(bDontCollapseNav)
{
this.createMenu(true);
_root.unitData.subBtnPress(unit,subUnit);
}
else
{
this.onFolderClicked(_loc3_,true);
}
}
function unitBtnClicked(unit, bDontCollapseNav)
{
var _loc3_ = {};
_loc3_.nodeData = this.createNavObject(this.arrNavigation[unit]);
_loc3_.nodeData.nodePath = [unit];
trace("dumping this unitNodeData ");
trace(_loc3_.nodeData.label);
if(bDontCollapseNav)
{
this.onFolderClicked(_loc3_,false);
}
else if(_loc3_.nodeData.label == "iTest")
{
this.onFileClicked(_loc3_);
this.clearMenu();
_root.unitData.homeBtnPress();
}
else
{
this.onFolderClicked(_loc3_,true);
}
}
function getUnitInfo(nodePath, difference)
{
if(difference != undefined)
{
nodePath[nodePath.length - 1] += difference;
}
this.getUnitInfoByNode(this.arrNavigation,nodePath);
return this.objectHolder;
}
function getUnitInfoByNode(arrNav, nodePath)
{
if(nodePath.length == 2 && arrNav[nodePath[0]].arrActivities)
{
var _loc4_ = nodePath[0];
nodePath.shift();
this.getUnitInfoByNode(arrNav[_loc4_].arrActivities.arrSubSections,nodePath);
}
else if(nodePath.length == 1)
{
this.objectHolder = arrNav[nodePath[0]];
}
else
{
_loc4_ = nodePath[0];
nodePath.shift();
this.getUnitInfoByNode(arrNav[_loc4_].arrSubSections,nodePath);
}
}
function hideDummys()
{
trace("initialise");
this.navigation_mc.dummy1_mc.swapDepths(0);
this.navigation_mc.dummy1_mc.removeMovieClip();
this.navigation_mc.dummy2_mc.swapDepths(0);
this.navigation_mc.dummy2_mc.removeMovieClip();
this.navigation_mc.dummy3_mc.swapDepths(0);
this.navigation_mc.dummy3_mc.removeMovieClip();
this.navigation_mc.dummy4_mc.swapDepths(0);
this.navigation_mc.dummy4_mc.removeMovieClip();
this.navigation_mc.endSection.swapDepths(0);
this.navigation_mc.endSection.removeMovieClip();
}
function parseXML(navigationXML)
{
trace("asasassadfdfdfd");
var _loc3_ = undefined;
var _loc4_ = undefined;
var _loc5_ = undefined;
var _loc6_ = undefined;
this.arrNavigation = [];
_loc4_ = navigationXML.firstChild;
_loc3_ = 0;
while(_loc3_ <= _loc4_.childNodes.length)
{
if(_loc4_.childNodes[_loc3_].nodeName == "folder")
{
_loc5_ = this.extractFolder(_loc4_.childNodes[_loc3_],_loc3_,false);
this.arrNavigation.push(_loc5_);
}
else if(_loc4_.childNodes[_loc3_].nodeName == "file")
{
_loc6_ = this.extractFile(_loc4_.childNodes[_loc3_],_loc3_);
this.arrNavigation.push(_loc6_);
}
_loc3_ = _loc3_ + 1;
}
this.addNodePaths(this.arrNavigation,[]);
_root.unitData.getNavArr(this.arrNavigation);
this.initialDisplay();
}
function extractFolder(folderTag, nodeNo, isActivity)
{
var _loc4_ = {};
_loc4_.label = folderTag.attributes.label;
if(folderTag.attributes.title)
{
_loc4_.title = folderTag.attributes.title;
}
if(folderTag.attributes.image)
{
_loc4_.image = folderTag.attributes.image;
}
var _loc7_ = false;
if(folderTag.attributes.label == "Activities")
{
isActivity = true;
_loc7_ = true;
}
_loc4_.refNo = nodeNo;
_loc4_.arrSubSections = [];
_loc4_.bFolder = true;
_loc4_.draw = false;
var _loc2_ = 0;
while(_loc2_ <= folderTag.childNodes.length)
{
if(folderTag.childNodes[_loc2_].nodeName == "folder")
{
_loc4_.arrSubSections.push(this.extractFolder(folderTag.childNodes[_loc2_],_loc2_,isActivity));
}
else if(folderTag.childNodes[_loc2_].nodeName == "file")
{
_loc4_.arrSubSections.push(this.extractFile(folderTag.childNodes[_loc2_],_loc2_,isActivity));
}
_loc2_ = _loc2_ + 1;
}
if(isActivity && !_loc7_)
{
if(_loc4_.arrSubSections.length > 1)
{
var _loc6_ = new Object();
_loc6_.bFolder = false;
_loc6_.draw = false;
_loc6_.label = _loc4_.label;
_loc6_.arrActivities = {};
_loc6_.link = {};
_loc6_.link.url = "activities.swf";
_loc6_.arrActivities = _loc4_;
_loc6_.activitySectionFile = true;
_loc4_ = _loc6_;
}
else
{
_loc4_ = _loc4_.arrSubSections[0];
_loc4_.activitySectionFile = true;
}
}
return _loc4_;
}
function extractFile(fileTag, nodeNo, isActivity)
{
var _loc4_ = {};
var _loc9_ = undefined;
var _loc6_ = undefined;
var _loc5_ = undefined;
_loc4_.link = {};
_loc4_.bFolder = false;
_loc4_.isActivity = isActivity;
_loc4_.draw = false;
if(fileTag.attributes.label)
{
_loc4_.label = fileTag.attributes.label;
}
if(fileTag.attributes.url)
{
_loc4_.link.url = fileTag.attributes.url;
}
if(fileTag.attributes.title)
{
_loc4_.title = fileTag.attributes.title;
}
if(fileTag.attributes.activityFile)
{
_loc4_.link.activityFile = fileTag.attributes.activityFile;
}
if(fileTag.attributes.PDF)
{
var _loc8_ = new Array();
_loc9_ = fileTag.attributes.PDF;
_loc6_ = _loc9_.split("\\");
var _loc2_ = 0;
while(_loc2_ < _loc6_.length)
{
_loc5_ = _loc6_[_loc2_].split(".");
var _loc7_ = {};
_loc7_.unit = _loc5_[0];
_loc7_.subSection = _loc5_[1];
_loc8_.push(_loc7_);
_loc2_ = _loc2_ + 1;
}
_loc4_.link.pdf = _loc8_;
}
if(fileTag.attributes.type)
{
_loc4_.type = fileTag.attributes.type;
if(fileTag.attributes.type != fileTag.previousSibling.attributes.type && fileTag.attributes.type != fileTag.nextSibling.attributes.type)
{
this.typeCount = 0;
}
else if(fileTag.attributes.type != fileTag.previousSibling.attributes.type)
{
this.typeCount = 1;
}
else
{
this.typeCount = this.typeCount + 1;
}
}
if(fileTag.attributes.header)
{
_loc4_.header = fileTag.attributes.header;
}
if(fileTag.attributes.rubric)
{
_loc4_.rubric = fileTag.attributes.rubric;
}
if(fileTag.parentNode.attributes.label == "Mini-Grammar")
{
_loc4_.referenceFile = true;
_loc8_ = new Array();
_loc7_ = {};
if(fileTag.attributes.PDF)
{
_loc7_.unit = fileTag.attributes.PDF;
}
else
{
_loc7_.unit = nodeNo + 1;
}
_loc8_.push(_loc7_);
_loc4_.link.pdf = _loc8_;
}
if(fileTag.parentNode.parentNode.attributes.label == "Activities")
{
_loc4_.activitySectionFile = true;
}
if(fileTag.parentNode.attributes.label == "Grammar")
{
_loc4_.grammarSectionFile = true;
}
_loc4_.refNo = nodeNo;
return _loc4_;
}
function addNodePaths(arr, currNode)
{
var _loc2_ = 0;
while(_loc2_ < arr.length)
{
arr[_loc2_].nodePath = currNode.concat([_loc2_]);
if(arr[_loc2_].arrSubSections)
{
this.addNodePaths(arr[_loc2_].arrSubSections,arr[_loc2_].nodePath);
}
_loc2_ = _loc2_ + 1;
}
}
function showNavigation(bValue)
{
this.navigation_mc._visible = bValue;
}
}