Hi
we have a shopping basket data grid component called basket info. we have various items on the stage - when you click on them they are added to the datagrid.
everything works fine apart from the remove item button.we are trying to make it work so that when you select an item in the basket , you can click the remove button to delete it and update the price
has anyone got any ideas?
thanks
alex
gregsie74@yahoo.com- my email address
code follows------>
var aItem:Array = new Array();
aItem[“toys”] = {instance:this.shopPage.toyShelf, product:“Toys”, price:34.99, quantity:0};
aItem[“calender”] = {instance:this.shopPage.calender, product:“Jonathan’s Book 2009 calender”, price:1.99, quantity:0};
aItem[“mugs”] = {instance:this.shopPage.mugs, product:“Mugs”, price:3.99, quantity:0};
aItem[“clothes”] = {instance:this.shopPage.clothesRail, product:“Clothes for your wardrobe”, price:9.99, quantity:0};
aItem[“caps”] = {instance:this.shopPage.capsBtn, product:“Fun cap”, price:6.99, quantity:0};
aItem[“magnets”] = {instance:this.shopPage.magnets, product:“Magnets”, price:1.99, quantity:0};
aItem[“sweets”] = {instance:this.shopPage.tillPoint.sweetJar, product:“Assorted sweets”, price:0.50, quantity:0};
aItem[“badges”] = {instance:this.shopPage.badges, product:“Badge”, price:1.99, quantity:0};
aItem[“key chains”] = {instance:this.shopPage.keyChains, product:“Keychain”, price:1.99, quantity:0};
//for (var i in aItem) {
shopPagePopup.addItemBtn.onRelease = function() {
trace(“add item btn clicked”);
aItem[currentProduct].quantity++;
updateDatagrid();
_root.shoppingBasketBTN.basketAnim.gotoAndPlay(2);
};
this.basket.clearBasketBtn.onRelease = function() {
clearDataGrid();
};
//}
this.basket.removeItemBtn.onRelease = function() {
//aItem[currentProduct].quantity–;
//totalPrice -= aItem*.quantity * aItem*.price;
trace("remove item btn clicked");
var emptyArray:Array = new Array();
//this.basket.basketInfo.dataProvider = emptyArray;
var removeIt = this.basket.basketInfo.selectedIndex;
this.basket.basketInfo.dataProvider = removeIt;
this.basket.basketInfo.dataProvider.removeItemAt(this.basket.basketInfo.selectedIndex);
this.basket.basketInfo.selectedIndex = removeIt -1;
//this.basket.basketInfo.dataProvider.removeItemAt(this.basket.basketInfo.focusedCell);
//updateDatagrid();
}
//--------------------------------------- functions ----------------------------------------------//
function updateDatagrid():Void {
totalPrice = 0.00;
var aBasket:Array = new Array();
for (var i in aItem) {
if (aItem*.quantity>0) {
aBasket.push({Product:aItem*.product, Quantity:aItem*.quantity, Price:aItem*.priceaItem.quantity});
totalPrice += aItem*.quantityaItem.price;
}
}
this.basket.basketInfo.dataProvider = aBasket;
this.basket.basketInfo.vScrollPolicy = “auto”;
this.basket.tTotal.text = totalPrice;
}
this.basket.basketInfo.multipleSelection = true;
function clearDataGrid():Void {
totalPrice = 0.00;
var emptyArray:Array = new Array();
this.basket.basketInfo.dataProvider = emptyArray;
this.basket.basketInfo.vScrollPolicy = “auto”;
this.basket.tTotal.text = totalPrice;
this.basket.basketInfo.items.clear();
}
//////////////////////