livewire_cjp
asked on
Array out of an Object/sharedObject?
I am using a sharedObject in a shopping cart, I can add items to it and even display in a grid but cannot for the life of me get the data back out into variables or an Array. I just keep getting 'undefined'.
CREATION of the sharedObject
var shopCart:Object = SharedObject.getLocal("Fan FestCart") ;
if (shopCart.data.shopList == undefined){
shopCart.data.shopList = [];
}else{
};
IN THE GRID
cartGrid.dataProvider = shopCart.data.shopList;
ADDING TO IT;
shopCart.data.shopList.pus h({Name:de tailName, UPC:detailUpc, Color:detailColor, Size:detailSize, Price:detailPrice, Weight:detailWeight, Quantity:detailQuan, Total:detailTot, TotWeight:detailTotWeight} );
shopCart.data.flush();
COPYING TO AN ARRAY
????
CREATION of the sharedObject
var shopCart:Object = SharedObject.getLocal("Fan
if (shopCart.data.shopList == undefined){
shopCart.data.shopList = [];
}else{
};
IN THE GRID
cartGrid.dataProvider = shopCart.data.shopList;
ADDING TO IT;
shopCart.data.shopList.pus
shopCart.data.flush();
COPYING TO AN ARRAY
????
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you please upload your sample FLA to have a closer look.
or mail it ,, my email is in PROFILE..
Rgds
Aneesh
or mail it ,, my email is in PROFILE..
Rgds
Aneesh
try this:
you have to get the latest data from shareObject before assigning it to data to grid
----------
// just re-intialize the "shopCart" object
var shopCart:Object = SharedObject.getLocal("Fan FestCart") ;
cartGrid.dataProvider = shopCart.data.shopList;;
----------
Rgds
Aneesh
you have to get the latest data from shareObject before assigning it to data to grid
----------
// just re-intialize the "shopCart" object
var shopCart:Object = SharedObject.getLocal("Fan
cartGrid.dataProvider = shopCart.data.shopList;;
----------
Rgds
Aneesh
ASKER
I appreciate the try but I ended up figuring a way myself. shopCart.data.shopList[i]. ["fieldnam e"] It is not a perfect way but I can get the data out, and sincer I cannot pass an Array to the ASP page to send the mail it works. Now if I can just figure out a way to dynamically create and name variables I'd really be set.
var variableName[i] doen't work
var variableName[i] doen't work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
grid doesn't populate and I'm still where I was.