Maybe the wrong place...?

Maybe an off topic question, but I’ll try anyway. Hopefully someone have some time to explain what’s really going on here. I’m trying to figure out how this menu works but can’t seem to quite understand it. Maybe just a short guide and I will be forever grateful! :wink:


import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, FuseFMP, PennerEasing);
ZigoEngine.simpleSetup(Shortcuts);

// VARS
// Height of items
var spacing:Number = 20;
// Speed of menu
var speed:Number = 1;
// Easing
var ease:String = "easeOutBack";

// MAINMENU
var mm_array:Array = ["MAIN 1", "MAIN 2", "MAIN 3", "MAIN 4"];

// SUBMENU
// Sub 1
var sm1_array:Array = ["sub 1", "sub 2"];
// Sub 2
var sm2_array:Array = ["sub 1", "sub 2"];
// Sub 3
var sm3_array:Array = ["sub 1", "sub 2"];
// Sub 4
var sm4_array:Array = ["sub 1", "sub 2"];

var submenu_array:Array = [];

// FUNCTIONS
_global.$tweenManager.broadcastEvents = true;
// Main menu
function createMainMenu() {
	var a = 1;
	var total = mm_array.length;
	while (a<=total) {
		ypos = ((a-1)*spacing)+1;
		attachMovie("mainnav_mc", "mainnav"+a+"_mc", this.getNextHighestDepth()+100, {_x:0, _y:ypos});	// attach the movieClip
		var nc = this["mainnav"+a+"_mc"];
		nc.menutext = mm_array[(a-1)];	// set the title text for each button
		nc.itemnum = a;	// set the menu #
		a++;
	}
}
function moveMenu(num) {
	if ((_root.collapsed == true) || (_root.selectedmenu != num)) {
		var array = "sm"+num+"_array";
		var totalsm = eval(array).length;
		var totalmm = mm_array.length;
		var a = 1;
		while (a<=totalmm) {
			mc = this["mainnav"+a+"_mc"];
			if (a>num) {
				var ypos = (((a-1)*spacing)+1)+totalsm*(spacing+1);
				mc.tween("_y", ypos, speed, ease); 
			} else {
				var ypos = ((a-1)*spacing)+1;
				if (a == num) {
					nypos = ypos;
					mc.tween("_y", ypos, speed, ease, 0, onEnd(num, nypos));
				} else {
					mc.tween("_y", ypos, speed, ease);
				}
			}
			a++;
		}
		_root.collapsed = false;
	} else {
		contractMenu()
		_root.collapsed = true;
	}
}
function onEnd(num, nypos) {
	_root.num = num;
	createSubMenu(num, nypos);
}
function contractMenu() {
	var c = 1;
	while (c<=submenu_array.length) {
		removeMovieClip("subnav"+c+"_mc");
		c++;
	}
	var g = 1;
	while (g<=mm_array.length) {
		ypos = ((g-1)*spacing)+1;
		this["mainnav"+g+"_mc"].tween("_y", ypos, speed, ease);
		g++;
	}
}
function createSubMenu(num, nypos) {
    var array = "sm"+num+"_array";
    var totalsm = eval(array).length;
    var ypos = nypos;
    var c = 1;
    while (c<=submenu_array.length) {
        removeMovieClip("subnav"+c+"_mc");
        c++;
    }
    submenu_array = [];
    var a = 1;
    while (a<=totalsm) {
        ypos = ypos+spacing;
        attachMovie("subnav_mc", "subnav"+a+"_mc", a+30, {_x:0, _y:ypos});
        nc = this["subnav"+a+"_mc"];
        nc._alpha = 0;
        nc.itemnum = a;
        nc.menutext = eval(array)[(a-1)];
        nc.alphaTo(100, 2);
        submenu_array.push("subnav"+a+"_mc");
        a++;
		}
}
// Over & Out on buttons
function over () {
	this.tween("_x", 2, .5, 'easeOutExpo');
}
function out () {
	this.tween("_x", 0, .5, 'easeOutExpo');
}

// BUILD MENU
_root.collapsed = true;
createMainMenu();

// MAIN BTN
var mainNbr:Number;
for (mainNbr = 0; mainNbr<=mm_array.length; mainNbr++) {
	var mainBtn = this["mainnav"+mainNbr+"_mc"];
	mainBtn.mainBtnText.autoSize = "left";
	mainBtn.onRollOver = over;
	mainBtn.onRollOut = out;
    mainBtn.onRelease = function() {
		trace (this.itemnum);
		moveMenu(this.itemnum);
		_root.selectedmenu = itemnum;
	}
}

// SUB BTN
this.onEnterFrame = function() {
	if (itemnum == 1) {
		this._y = this["mainnav"+_root.num+"_mc"]._y+spacing;
	} else {
		this._y = (this["mainnav"+_root.num+"_mc"]._y+spacing)+((spacing+1)*(itemnum-1));
	}
}