Ciao Ragazzi
ho questo problema:
Di seguito vi incollo l'AS di questo menu dinamico che pesca i dati da un file xml.
Ho preso il menu dalla raccolata clip del sito e vi ho apportato alcune moidifiche...
Il prob e che non riesco a visualizzare le immagini nella MC "Marco"
:maLOL:
sapete aiutarmi??? dove cavolo sbaglio ???
ecco il codice:
// Constructor
_global.Menu = function(data_file, ref) {
// Set the menu reference
this._p = ref;
// Read the menu info from the xml file
this.XmlData = new XML();
this.XmlData.ignoreWhite = true;
this.XmlData._p = this;
this.XmlData.load(data_file);
this.XmlData.onLoad = function(ok) {
if (ok) {
this._p.SetVariables();
}
};
delete ref;
delete data_file;
};
// Parse the information loaded
Menu.prototype.SetVariables = function() {
// Set the vars readed from the xml file
this.Root = this.XmlData.childNodes;
this.Titles = new Array();
this.Links = new Array();
this.Tg = new Array();
this.Descriptions = new Array();
this.Immagini = new Array();
for (i=0; i<this.Root.length; i++) {
if (this.Root[i].nodeName.toUpperCase() == "MENU") {
this.Nodes = this.Root[i].childNodes;
for (k=0; k<this.Nodes.length; k++) {
this.Item++;
this.Titles.push(this.Nodes[k].attributes.id.toString());
this.Links.push(this.Nodes[k].attributes.page.toString());
this.Tg.push(this.Nodes[k].attributes.tg.toString());
this.Descriptions.push(this.Nodes[k].childNodes.toString());
this.Immagini.push(Nodes[K].attributes.img.toString;
}
}
}
delete this.Root;
delete this.Nodes;
delete this.XmlData;
this.DrawMenu();
};
// Construct the UI
Menu.prototype.DrawMenu = function() {
// Use vars and arrays to contruct the menu
for (i=0; i<this.Item; i++) {
this._p.attachMovie("ITEM", "Item" add i, i);
this._mc = eval(this._p add ".Item" add i);
this._mc._x = 300;
this._mc._y = 80+45*i;
this._mc.Title.label.htmlText = this.Titles[i].toUpperCase();
this._mc.Graphic.Slide.label.htmlText = this.Titles[i].toUpperCase();
this._mc.Link.Description.htmlText = "» " add this.Descriptions[i];
this._mc.Link.$link = this.Links[i];
this._mc.Link.$tg = this.Tg[i];
this._mc.Marco.loadMovie(this.Immagini[i]);
this.format = new TextFormat();
this.format.align = "right";
this._mc.Title.label.setTextFormat(this.format);
this._mc._id = i;
delete this.format;
}
this.SetAction();
this.SetActive(0);
};
// Set the action for the menu tabs
Menu.prototype.SetAction = function() {
for (i in this.Titles) {
this._mc = eval(this._p add ".Item" add i);
this._mc._ref = this;
this._mc.$active = (i == 0) ? true : false;
this._mc.Ico.gotoAndPlay((i == 0) ? "SlideIn" : "SlideOut");
this._mc.onRelease = function() {
if (this.$active == false) {
this._ref.SetActive(this._id);
}
};
this._mc.Link.onMouseUp = function() {
if (this.hitTest(_xmouse, _ymouse, true) && (this._parent.$active == true)) {
getURL(this.$Link, this.$Tg);
}
};
}
};
// Set the visualization options
Menu.prototype.SetActive = function(id) {
for (i in this.Titles) {
this._mc = eval(this._p add ".Item" add i);
// Move Title And Graphics of the Mc
this._mc.Ico.gotoAndPlay((id == i) ? "SlideIn" : (this._mc._currentframe != 1 && this._mc.$active == true) ? "SlideOut" : null);
this._mc.gotoAndPlay((id == i) ? "UnActive" : (this._mc._currentframe == 1) ? "Stop" : (this._mc.$active == true) ? "Active" : null);
this._mc.$active = (id == i) ? true : (this._mc._currentframe == 1) ? this._mc.$active : false;
// Move the tabs (with easing) in the correct position
if (id<i) {
// Move top to bottom
if (this._mc.act != "GoToBt") {
this._mc.__t__ = 0;
this._mc.act = "GoToBt";
delete this._mc.onEnterFrame;
this._mc.onEnterFrame = function() {
if (this._y == (45*this._id+174)) {
delete this.onEnterFrame;
this.act = "";
delete this._mc._x0;
delete this._mc._y0;
delete this._mc._x1;
delete this._mc._y1;
delete this._mc.spd;
delete this._mc.__t__;
}
this.moveFromTo(this._x, this._y, this._x, (45*this._id+150), 0.02);
};
}
} else if (id>=i) {
// Move bottom to top
if (this._mc.act != "GoToTp") {
this._mc.__t__ = 0;
this._mc.act = "GoToTp";
delete this._mc.onEnterFrame;
this._mc.onEnterFrame = function() {
if (this._y == 45*this._id) {
delete this.onEnterFrame;
this.act = "";
delete this._mc._x0;
delete this._mc._y0;
delete this._mc._x1;
delete this._mc._y1;
delete this._mc.spd;
delete this._mc.__t__;
}
this.moveFromTo(this._x, this._y, this._x, 45*this._id, 0.02);
};
}
}
}
delete id;
};
// Move Clips
MovieClip.prototype.moveFromTo = function(xFrom, yFrom, xTo, yTo, speed) {
this.x0 = xFrom == undefined ? this._x : xFrom;
this.y0 = yFrom == undefined ? this._y : yFrom;
this.x1 = xTo == undefined ? xFrom : xTo;
this.y1 = yTo == undefined ? yFrom : yTo;
this.spd = speed == undefined || speed>1 ? 0.0125 : speed;
this.__t__ += this.spd;
this._x = Math.round(this.x0+(this.x1-this.x0)*this.__t__);
this._y = Math.round(this.y0+(this.y1-this.y0)*this.__t__);
};
questo invece il file xml
<?xml version="1.0"?>
<MENU>
<ITEM id="home" page="pagina1.html" tg="_blank" img="immagini/01.gif">Dalla moda all'arredamento, gli stilisti oggi vestono anche la casa, improntando al proprio stile mobili, tessuti, cuscini, piastrelle e accessori.
Ecco le nuove collezioni casa presentate in occasione dell'ultimo Salone del Mobile di Milano da Armani, Versace, Agatha Ruiz de la Prada, Missoni, Etro, Fendi.</ITEM>
<ITEM id="works" page="pagina2.html" tg="_blank" img="02.gif">I miei lavori, esperimenti e progetti</ITEM>
<ITEM id="mission" page="pagina3.html" tg="_blank" img="03.gif">Il mio curriculum</ITEM>
<ITEM id="friends" page="pagina4.html" tg="_blank">Pagina dedicata agli amici</ITEM>
<ITEM id="credits" page="pagina5.html" tg="_blank">Onore e gloria a ...</ITEM>
<ITEM id="contact" page="pagina6.html" tg="_blank">Come contattarmi ...</ITEM>
<ITEM id="sport" page="pagina7.html" tg="_blank">Prova ...</ITEM>
</MENU>

:maLOL:
Rispondi quotando
