_global.aCardItems = new Array();
function addContentToContainer():Void {
// Add the Table header to "mcEmptyScrollPaneContainer"
this.mcEmptyScrollPane.spEmpty.attachMovie("cardHeader", "mcCardHeader", 200, {_x:2, _y:2});
this.onEnterFrame = function() {
delete this.onEnterFrame;
// add items to card display
_level0.tTest.text = _global.aCardItems.length;
var nTotalPrice:Number;
for (var i = 0; i<_global.aCardItems.length; i++) {
this.mcEmptyScrollPane.spEmpty.attachMovie("cardEntry", "mcCardEntry"+i, i, {_x:0, _y:(30*i)+70});
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tItem.text = _global.aCardItems[i]['id'];
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tName.text = _global.aCardItems[i]['name'];
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tNumber.value = Number(_global.aCardItems[i]['number']);
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tPrice.text = _global.aCardItems[i]['single'];
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tSubtotal.text = _global.aCardItems[i]['number']*Number(_global.aCardItems[i]['single']);
nTotalPrice += Number(this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tSubtotal.text);
// Controller for "update" button
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].btUpdate.onRelease = function() {
var lvItem:LoadVars = new LoadVars();
lvItem.item = this._parent.tItem.text;
lvItem.number = this._parent.tNumber.text;
if (this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].tNumber.text == 0) {
lvItem.action = "delete";
} else {
lvItem.action = "update";
}
lvItem.sendAndLoad("/de/katalog/php/shoppingcard.php", lvItem, "POST");
this._parent._parent._parent._parent.emptyContainerMC();
this._parent._parent._parent._parent.getCardItems();
this._parent._parent._parent._parent.addContentToContainer();
};
// Controller for "delete item" button
this.mcEmptyScrollPane.spEmpty["mcCardEntry"+i].mcDelete.onRelease = function() {
var lvItem:LoadVars = new LoadVars();
lvItem.item = this._parent.tItem.text;
lvItem.action = "delete";
lvItem.sendAndLoad("/de/katalog/php/shoppingcard.php", lvItem, "POST");
this._parent._parent._parent._parent.emptyContainerMC();
this._parent._parent._parent._parent.getCardItems();
this.onEnterFrame = function() {
delete this.onEnterFrame;
this._parent._parent._parent._parent.addContentToContainer();
};
};
}
// end of for
// ----------------------- <add "total price" mc to display> ------------------------------------------- \\
this.mcEmptyScrollPane.spEmpty.attachMovie("cardTotalPrice", "mcCardTotalPrice", 500);
this.mcEmptyScrollPane.spEmpty.mcCardTotalPrice._y = (30*_global.aCardItems.length)+70;
this.mcEmptyScrollPane.spEmpty.mcCardTotalPrice._x = 0;
this.mcEmptyScrollPane.spEmpty.mcCardTotalPrice.tTotalPrice.text = "";
this.mcEmptyScrollPane.spEmpty.mcCardTotalPrice.tTotalPrice.text = nTotalPrice;
// ------------------------ </add "total price" mc to display> ----------------------------------------- \\
// ---------------- <create button to go to the "terms section"> ---------------------------------------------------------------------------------------- \\
this.mcEmptyScrollPane.spEmpty.createClassObject(Button, "btTerms", 4);
this.onEnterFrame = function() {
delete this.onEnterFrame;
this.mcEmptyScrollPane.spEmpty.btTerms.label = "Ich erkläre mich mit den AGB einverstanden";
this.mcEmptyScrollPane.spEmpty.btTerms._width = 270;
this.mcEmptyScrollPane.spEmpty.btTerms._x = (this.width-(this.mcEmptyScrollPane.spEmpty.btTerms._width));
this.mcEmptyScrollPane.spEmpty.btTerms._y = (this.height-(this.mcEmptyScrollPane.spEmpty.btTerms._height));
// Event Handler for Terms
this.mcEmptyScrollPane.spEmpty.btTerms.onRelease = function() {
this._parent._parent.gotoAndStop('form');
};
// ---------------- </create button to go to the next section> ------------------------- \\
};
}; // end this.onEnterFrame
}
function emptyContainerMC():Void {
this.mcEmptyScrollPane.spEmpty.unloadMovie();
}
function getCardItems():Void {
// Get XML
var xmlItems:XML = new XML();
xmlItems.ignoreWhite = true;
xmlItems.onLoad = function(bSuccess:Boolean) {
if (bSuccess) {
_global.aCardItems = new Array();
// delete previous array entries
var xnItem:XMLNode;
var xnName:XMLNode;
var xnDescription:XMLNode;
var xnPrice:XMLNode;
_global.bLoadedOK = true;
var xnRoot:XMLNode = this.firstChild;
for (var i = 0; i<xnRoot.childNodes.length; i++) {
_global.aCardItems[i] = new Array();
xnItem = xnRoot.childNodes[i];
_global.aCardItems[i]['id'] = xnItem.attributes.id;
_global.aCardItems[i]['number'] = xnItem.attributes.number;
_global.aCardItems[i]['vpe'] = xnItem.attributes.vpe;
xnName = xnItem.firstChild;
_global.aCardItems[i]['name'] = xnName.firstChild.nodeValue;
xnDescription = xnName.nextSibling;
_global.aCardItems[i]['description'] = xnDescription.firstChild.nodeValue;
xnPrice = xnDescription.nextSibling;
_global.aCardItems[i]['ab1'] = xnPrice.attributes.ab1;
_global.aCardItems[i]['ab4'] = xnPrice.attributes.ab4;
_global.aCardItems[i]['ab6'] = xnPrice.attributes.ab6;
_global.aCardItems[i]['ab12'] = xnPrice.attributes.ab12;
_global.aCardItems[i]['discounted'] = xnPrice.attributes.discounted;
// Berechnung des Rabbats und Gesamtpreises
if (xnItem.attributes.number>=12) {
_global.aCardItems[i]['single'] = xnPrice.attributes.ab12;
} else if (xnItem.attributes.number>=6) {
_global.aCardItems[i]['single'] = xnPrice.attributes.ab6;
} else if (xnItem.attributes.number>=4) {
_global.aCardItems[i]['single'] = xnPrice.attributes.ab4;
} else {
_global.aCardItems[i]['single'] = xnPrice.attributes.ab1;
}
}
}
};
xmlItems.load("de/katalog/php/shoppingcard.php?action=details");
}
function showCard():Void {
this.attachMovie("emptyScrollPane", "mcEmptyScrollPane", 0);
this.getCardItems();
this.onEnterFrame = function() {
delete this.onEnterFrame;
this.addContentToContainer();
};
}