Link to home
Start Free TrialLog in
Avatar of livewire_cjp
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("FanFestCart");
if (shopCart.data.shopList == undefined){
      shopCart.data.shopList = [];
}else{
};

IN THE GRID
cartGrid.dataProvider = shopCart.data.shopList;

ADDING TO IT;
shopCart.data.shopList.push({Name:detailName, UPC:detailUpc, Color:detailColor, Size:detailSize, Price:detailPrice, Weight:detailWeight, Quantity:detailQuan, Total:detailTot, TotWeight:detailTotWeight});
      shopCart.data.flush();

COPYING TO AN ARRAY
????
SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of livewire_cjp
livewire_cjp

ASKER

You know, it looked good but...
grid doesn't populate and I'm still where I was.
can you please upload your sample FLA to have a closer look.

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("FanFestCart");
cartGrid.dataProvider = shopCart.data.shopList;;
----------

Rgds
Aneesh
I appreciate the try but I ended up figuring a way myself.  shopCart.data.shopList[i].["fieldname"]  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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial