Stage.scaleMode = "noScale";
// PERSONALIZZAZIONE DEL MENU
x0 = 0;
// posizione orizzontale
y0 = 150;
// posizione verticale
colMainOver = "0xDD0000";
// colore al rollOver delle sezioni
colMainOut = "0xBB0000";
// colore al rollOut delle sezioni
colSubOver = "0xBB0000";
// colore al rollOver dei sub menu
colSubOut = "0xE3A2A2";
// colore al rollOut dei sub menu
//
myMenu = new XML();
myMenu.ignoreWhite = true;
myMenu.onLoad = function(success) {
if (success) {
nodes = this.firstChild.childNodes;
for (var i = 0; i<nodes.length; i++) {
var item = nodes[i].attributes.nome;
var gurl = nodes[i].attributes.gurl;
var lswf = nodes[i].attributes.lswf;
var trgt = nodes[i].attributes.trgt;
var mc = createEmptyMovieClip('menu'+i, i);
var clip = mc.attachMovie('main', 'main'+i, i+999);
clip._x = x0;
clip._y = y0+i*(clip.bg._height+1);
clip.old = clip._y;
clip.testo.text = clip.ombra.text=item;
clip.g = gurl;
clip.l = lswf;
clip.t = trgt;
col = new Color(clip.bg);
col.setRGB(colMainOut);
for (var j = 0; j<nodes[i].childNodes.length; j++) {
var sub = nodes[i].childNodes[j].attributes.nome;
var link = nodes[i].childNodes[j].attributes.gurl;
var movie = nodes[i].childNodes[j].attributes.lswf;
var window = nodes[i].childNodes[j].attributes.trgt;
var clip2 = mc.attachMovie('sub', 'sub'+j, j);
clip2._x = x0;
clip2._y = clip._y+(j+1)*(clip.bg._height+1);
clip2.old = clip2._y;
clip2._y = clip._y;
clip2.testo.text = clip2.star.subtesto=sub;
clip2.g = link;
clip2.l = movie;
clip2.t = window;
col = new Color(clip2.bg);
col.setRGB(colSubOut);
}
}
genera();
}
};
myMenu.load(url);
function genera() {
for (i=0; i<nodes.length; i++) {
_root['menu'+i]['main'+i].bg.useHandCursor = true;
for (z=0; z<nodes[i].childNodes.length; z++) {
_root['menu'+i]['sub'+z].bg.onRollOver = function() {
col = new Color(this);
col.setRGB(colSubOver);
this._parent.star.gotoAndStop(2);
};
_root['menu'+i]['sub'+z].bg.onRollOut = _root['menu'+i]['sub'+z].bg.onReleaseOutside = function () {
col = new Color(this);
col.setRGB(colSubOut);
which = _root[this._parent._parent._name][this._parent._name];
if (which != _root[menu][before]) {
this._parent.star.gotoAndStop(1);
}
};
_root['menu'+i]['sub'+z].bg.onRelease = function() {
if (this._parent.g != "") {
getURL(""+this._parent.g+"", ""+this._parent.t+"");
trace(this._parent.g);
trace(this._parent.t);
} else if (this._parent.l != "") {
loadMovie(""+this._parent.l+"", "_root.GRAFICA.SEZIONE");
trace(this._parent.l);
} else {
trace(this._parent.g);
trace(this._parent.l);
trace(this._parent.t);
}
_root[menu][before].star.gotoAndStop(1);
this._parent.star.gotoAndStop(2);
_root[menu][before].bg.enabled = true;
_root[menu][before].bg.useHandCursor = true;
this.enabled = false;
this.useHandCursor = false;
col = new Color(_root[menu][before].bg);
col.setRGB(0xE3A2A2);
before = this._parent._name;
menu = this._parent._parent._name;
};
}
_root['menu'+i]['main'+i].bg.onRollOver = function() {
col = new Color(this);
col.setRGB(colMainOver);
};
_root['menu'+i]['main'+i].bg.onRollOut = _root['menu'+i]['main'+i].bg.onReleaseOutside = function () {
col = new Color(this);
col.setRGB(colMainOut);
};
_root['menu'+i]['main'+i].bg.onRelease = function() {
// qui sotto do il comando per aprire il sottomenù
j = Number(this._parent._name.substring(4));
//la riga sotto ridefinisce la y dei bottoni principali quando si aprono i sottomenù
newY = nodes[j].childNodes.length*(this._height+1);
if (temp == j) {
this._parent.square.gotoAndStop(1);
//il codice sotto permette ai sottomenù di richiudersi
for (i=0; i<nodes.length; i++) {
_root['menu'+i]['main'+i].muovi(_root['menu'+i]['main'+i].old, 3);
for (z=0; z<nodes[i].childNodes.length; z++) {
_root['menu'+i]['sub'+z].muovi(_root['menu'+i]['main'+i].old, 3);
}
}
delete j;
} else {
this._parent.square.gotoAndStop(2);
if (this._parent.g != "") {
getURL(""+this._parent.g+"", ""+this._parent.t+"");
trace(this._parent.g);
trace(this._parent.t);
} else if (this._parent.l != "") {
loadMovie(""+this._parent.l+"", "_root.GRAFICA.SEZIONE");
trace(this._parent.l);
} else {
trace(this._parent.g);
trace(this._parent.l);
trace(this._parent.t);
}
for (i=0; i<=j; i++) {
_root['menu'+i]['main'+i].muovi(_root['menu'+i]['main'+i].old, 3);
for (z=0; z<nodes[i].childNodes.length; z++) {
_root['menu'+i]['sub'+z].muovi(_root['menu'+i]['main'+i].old, 3);
}
}
for (i=j+1; i<nodes.length; i++) {
_root['menu'+i]['main'+i].muovi(_root['menu'+i]['main'+i].old+newY, 3);
for (z=0; z<nodes[i].childNodes.length; z++) {
_root['menu'+i]['sub'+z].muovi(_root['menu'+i]['main'+i].old+newY, 3);
}
}
}
for (z=0; z<nodes[j].childNodes.length; z++) {
_root['menu'+j]['sub'+z].muovi(_root['menu'+j]['sub'+z].old, 3);
}
_root['menu'+temp]['main'+temp].square.gotoAndStop(1);
_root[menu][before].star.gotoAndStop(1);
_root[menu][before].bg.enabled = true;
_root[menu][before].bg.useHandCursor = true;
col = new Color(_root[menu][before].bg);
col.setRGB(colSubOut);
before = this._name;
temp = j;
for (i=0; i<=this._parent._name.substring(4); i++) {
_root['menu'+i]['main'+i].muovi(_root['menu'+i]['main'+i].old, 3);
}
};
}
}