compuboy1010
07-20-2005, 08:42 AM
For some reason the functions in the movie "mcProduct" are not called or they don't display the data. Why not?
The vars are global so why don't they display them? Or is the path to the textfields wrong? Also when a leaf of the tree is clicked the mcWelcome clips is supposed to fade away and then the product description is supposed to display but after it fades out I still have to doubleclick on a leaf of the tree and it will only load the mcProduct clip but not display anything.
stop();
xml_conn.trigger();
_global.aSpecs = new Array();
_global.sDescription;
_global.sAdvantages;
_global.sProductName;
_global.nCurrentPid;
_global.bLoadedOK = false;
customizeTree();
var treeListener:Object = new Object();
treeListener.target = tree;
function getProductData():Void {
// Get XML
var xmlProduct:XML = new XML();
xmlProduct.ignoreWhite = true;
xmlProduct.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
bLoadedOK = true;
var xnRoot:XMLNode = this.firstChild;
var xnProductName:XMLNode = xnRoot.firstChild;
sProductName = xnProductName.firstChild.nodeValue;
// Beschreibung
var xnDescription:XMLNode = xnProductName.nextSibling;
sDescription = xnDescription.firstChild.nodeValue;
// Vorteile
var xnAdvantages:XMLNode = xnDescription.nextSibling;
sAdvantages = "<ul>";
for (var i = 0; i<xnAdvantages.childNodes.length; i++) {
xnAdvantage = xnAdvantages.childNodes[i];
sAdvantages += "<li>"+xnAdvantage.firstChild.nodeValue+"</li>";
}
sAdvantages += "</ul";
var xnSpecs:XMLNode = xnAdvantages.nextSibling;
var xnAnmischverhaeltnis:XMLNode = xnSpecs.firstChild;
aSpecs['anmischverhaeltnis'] = xnAnmischverhaeltnis.firstChild.nodeValue;
var xnRuehrzeit:XMLNode = xnAnmischverhaeltnis.nextSibling;
aSpecs['ruehrzeit'] = xnRuehrzeit.firstChild.nodeValue;
var xnVz:XMLNode = xnRuehrzeit.nextSibling;
aSpecs['vz'] = xnVz.firstChild.nodeValue;
var xnAb:XMLNode = xnVz.nextSibling;
aSpecs['ab'] = xnAb.firstChild.nodeValue;
var xnEntf:XMLNode = xnAb.nextSibling;
aSpecs['entf'] = xnEntf.firstChild.nodeValue;
var xnHaerte30min:XMLNode = xnEntf.nextSibling;
aSpecs['haerte30min'] = xnHaerte30min.firstChild.nodeValue;
var xnHaerte60min:XMLNode = xnHaerte30min.nextSibling;
aSpecs['sHaerte60min'] = xnHaerte60min.firstChild.nodeValue;
var xnHaerte24h:XMLNode = xnHaerte60min.nextSibling;
aSpecs['sHaerte24h'] = xnHaerte24h.firstChild.nodeValue;
var xnDruckfest_1h:XMLNode = xnHaerte24h.nextSibling;
aSpecs['sDruckfest_1h'] = xnDruckfest_1h.firstChild.nodeValue;
var xnDruckfest_24h:XMLNode = xnDruckfest_1h.nextSibling;
aSpecs['sDruckfest_24h'] = xnDruckfest_24h.firstChild.nodeValue;
var xnAbbindeexpansion:XMLNode = xnDruckfest_24h.nextSibling;
aSpecs['abbindeexpansion'] = xnAbbindeexpansion.firstChild.nodeValue;
} else {
bLoadedOK = false;
}
};
xmlProduct.load("de/katalog/php/product.php?pid="+nCurrentPid);
}
function customizeTree():Void {
this.tree.setStyle("backgroundColor", "none");
// ...
this.tree.depthChild0._visible = false;
this.tree.depthChild0._alpha = 0;
}
// If the user clicked on a leaf of the product:
treeListener.change = function(evt:Object) {
var node = evt.target.selectedItem;
nCurrentPid = Number(node.attributes.value);
if (nCurrentPid) {
_level0.main.getProductData();
// if leaf was selected remove the welcome message if present
if (mcWelcome) {
mcWelcome.onEnterFrame = function() {
if (this._alpha>=0) {
this._alpha -= 5;
} else {
delete this.onEnterFrame;
}
};
}
if (bLoadedOK) { // if loaded successfully
_level0.main.tTest.text = "hello";
_level0.main.attachMovie("product", "mcProduct", 1, {_x:353, _y:277});
_level0.main.mcProduct.displayTitle();
_level0.main.mcProduct.displayDescription();
// event handlers for product info MCs
_level0.main.mcProduct.mcAdvantages.onRelease = function() {
_level0.main.mcProduct.displayAdvantages();
};
_level0.main.mcProduct.mcDescription.onRelease = function() {
_level0.main.mcProduct.displayDescription();
};
_level0.main.mcProduct.mcSpecs.onRelease = function() {
_level0.main.mcProduct.displaySpecs();
};
} else {
_level0.main.mcProduct.displayError();
}
}
};
tree.addEventListener('change', treeListener);
And this is the code on the main timeline of mcProduct.
function displayError():Void {
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.createTextField("error", 1, 10,10, 20,20);
this.error.text = "Fehler!";
}
function displayTitle():Void {
this.tProductName.text = sProductName;
_level0.main.tTest.text = sProductName;
}
function displayDescription():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.mcSection.attachMovie("productSlideshow", "mcProductSlideshow", 1, {_x:0, _y:30});
this.mcSection.createTextField("tDescription", 0, 160, 40, 230, 150);
this.mcSection.tDescription.multiline = true;
this.mcSection.tDescription.html = true;
this.mcSection.tDescription.wordWrap = true;
this.mcSection.tDescription.htmlText = sDescription;
}
function displayAdvantages():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.mcSection.attachMovie("advantages_box", "mcAdvantages_box", 1, {_x:50, _y:50});
this.mcSection.mcAdvantages_box.advantages.htmlTex t = sAdvantages;
}
function displaySpecs():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.section.attachMovie("specs_table", "mcSpecs_table", 1, {_x:10, _y:50});
this.mcSection.mcSpecs_table.tAnmischverhaeltnis.h tmlText = aSpecs['anmischverhaeltnis'];
// ...
this.mcSection.mcSpecs_table.tAbbindeexpansion.htm lText = aSpecs['abbindeexpansion'];
}
The vars are global so why don't they display them? Or is the path to the textfields wrong? Also when a leaf of the tree is clicked the mcWelcome clips is supposed to fade away and then the product description is supposed to display but after it fades out I still have to doubleclick on a leaf of the tree and it will only load the mcProduct clip but not display anything.
stop();
xml_conn.trigger();
_global.aSpecs = new Array();
_global.sDescription;
_global.sAdvantages;
_global.sProductName;
_global.nCurrentPid;
_global.bLoadedOK = false;
customizeTree();
var treeListener:Object = new Object();
treeListener.target = tree;
function getProductData():Void {
// Get XML
var xmlProduct:XML = new XML();
xmlProduct.ignoreWhite = true;
xmlProduct.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
bLoadedOK = true;
var xnRoot:XMLNode = this.firstChild;
var xnProductName:XMLNode = xnRoot.firstChild;
sProductName = xnProductName.firstChild.nodeValue;
// Beschreibung
var xnDescription:XMLNode = xnProductName.nextSibling;
sDescription = xnDescription.firstChild.nodeValue;
// Vorteile
var xnAdvantages:XMLNode = xnDescription.nextSibling;
sAdvantages = "<ul>";
for (var i = 0; i<xnAdvantages.childNodes.length; i++) {
xnAdvantage = xnAdvantages.childNodes[i];
sAdvantages += "<li>"+xnAdvantage.firstChild.nodeValue+"</li>";
}
sAdvantages += "</ul";
var xnSpecs:XMLNode = xnAdvantages.nextSibling;
var xnAnmischverhaeltnis:XMLNode = xnSpecs.firstChild;
aSpecs['anmischverhaeltnis'] = xnAnmischverhaeltnis.firstChild.nodeValue;
var xnRuehrzeit:XMLNode = xnAnmischverhaeltnis.nextSibling;
aSpecs['ruehrzeit'] = xnRuehrzeit.firstChild.nodeValue;
var xnVz:XMLNode = xnRuehrzeit.nextSibling;
aSpecs['vz'] = xnVz.firstChild.nodeValue;
var xnAb:XMLNode = xnVz.nextSibling;
aSpecs['ab'] = xnAb.firstChild.nodeValue;
var xnEntf:XMLNode = xnAb.nextSibling;
aSpecs['entf'] = xnEntf.firstChild.nodeValue;
var xnHaerte30min:XMLNode = xnEntf.nextSibling;
aSpecs['haerte30min'] = xnHaerte30min.firstChild.nodeValue;
var xnHaerte60min:XMLNode = xnHaerte30min.nextSibling;
aSpecs['sHaerte60min'] = xnHaerte60min.firstChild.nodeValue;
var xnHaerte24h:XMLNode = xnHaerte60min.nextSibling;
aSpecs['sHaerte24h'] = xnHaerte24h.firstChild.nodeValue;
var xnDruckfest_1h:XMLNode = xnHaerte24h.nextSibling;
aSpecs['sDruckfest_1h'] = xnDruckfest_1h.firstChild.nodeValue;
var xnDruckfest_24h:XMLNode = xnDruckfest_1h.nextSibling;
aSpecs['sDruckfest_24h'] = xnDruckfest_24h.firstChild.nodeValue;
var xnAbbindeexpansion:XMLNode = xnDruckfest_24h.nextSibling;
aSpecs['abbindeexpansion'] = xnAbbindeexpansion.firstChild.nodeValue;
} else {
bLoadedOK = false;
}
};
xmlProduct.load("de/katalog/php/product.php?pid="+nCurrentPid);
}
function customizeTree():Void {
this.tree.setStyle("backgroundColor", "none");
// ...
this.tree.depthChild0._visible = false;
this.tree.depthChild0._alpha = 0;
}
// If the user clicked on a leaf of the product:
treeListener.change = function(evt:Object) {
var node = evt.target.selectedItem;
nCurrentPid = Number(node.attributes.value);
if (nCurrentPid) {
_level0.main.getProductData();
// if leaf was selected remove the welcome message if present
if (mcWelcome) {
mcWelcome.onEnterFrame = function() {
if (this._alpha>=0) {
this._alpha -= 5;
} else {
delete this.onEnterFrame;
}
};
}
if (bLoadedOK) { // if loaded successfully
_level0.main.tTest.text = "hello";
_level0.main.attachMovie("product", "mcProduct", 1, {_x:353, _y:277});
_level0.main.mcProduct.displayTitle();
_level0.main.mcProduct.displayDescription();
// event handlers for product info MCs
_level0.main.mcProduct.mcAdvantages.onRelease = function() {
_level0.main.mcProduct.displayAdvantages();
};
_level0.main.mcProduct.mcDescription.onRelease = function() {
_level0.main.mcProduct.displayDescription();
};
_level0.main.mcProduct.mcSpecs.onRelease = function() {
_level0.main.mcProduct.displaySpecs();
};
} else {
_level0.main.mcProduct.displayError();
}
}
};
tree.addEventListener('change', treeListener);
And this is the code on the main timeline of mcProduct.
function displayError():Void {
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.createTextField("error", 1, 10,10, 20,20);
this.error.text = "Fehler!";
}
function displayTitle():Void {
this.tProductName.text = sProductName;
_level0.main.tTest.text = sProductName;
}
function displayDescription():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.mcSection.attachMovie("productSlideshow", "mcProductSlideshow", 1, {_x:0, _y:30});
this.mcSection.createTextField("tDescription", 0, 160, 40, 230, 150);
this.mcSection.tDescription.multiline = true;
this.mcSection.tDescription.html = true;
this.mcSection.tDescription.wordWrap = true;
this.mcSection.tDescription.htmlText = sDescription;
}
function displayAdvantages():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.mcSection.attachMovie("advantages_box", "mcAdvantages_box", 1, {_x:50, _y:50});
this.mcSection.mcAdvantages_box.advantages.htmlTex t = sAdvantages;
}
function displaySpecs():Void {
this.mcSection.removeMovieClip();
this.createEmptyMovieClip("mcSection", 0);
this.mcSection.moveTo(0, 0);
this.section.attachMovie("specs_table", "mcSpecs_table", 1, {_x:10, _y:50});
this.mcSection.mcSpecs_table.tAnmischverhaeltnis.h tmlText = aSpecs['anmischverhaeltnis'];
// ...
this.mcSection.mcSpecs_table.tAbbindeexpansion.htm lText = aSpecs['abbindeexpansion'];
}