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 ( == undefined){ = [];

cartGrid.dataProvider =;

ADDING TO IT;{Name:detailName, UPC:detailUpc, Color:detailColor, Size:detailSize, Price:detailPrice, Weight:detailWeight, Quantity:detailQuan, Total:detailTot, TotWeight:detailTotWeight});;

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh ChopraCommented:

it should be done this way:
//CREATION of the sharedObject
var shopCart:Object = SharedObject.getLocal("FanFestCart");
var my_local_array = [];
if ( != undefined){;
//cartGrid.dataProvider = my_local_array;


my_local_array.push({Name:"detailName", UPC:detailUpc, Color:detailColor, Size:detailSize, Price:detailPrice, Weight:detailWeight, Quantity:detailQuan, Total:detailTot, TotWeight:detailTotWeight});;;
livewire_cjpAuthor Commented:
You know, it looked good but...
grid doesn't populate and I'm still where I was.
Aneesh ChopraCommented:
can you please upload your sample FLA to have a closer look.

or mail it ,, my email is in PROFILE..

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Aneesh ChopraCommented:
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 =;;

livewire_cjpAuthor Commented:
I appreciate the try but I ended up figuring a way myself.[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
Hi livewire_cjp,

To make dynamically named variables:

this["<nameString>" + i] = <whatever>;
set("<nameString>" + i, <whatever>);

<nameString> can be empty (ie. "")

Basically you're just creating a string for the new variable to be called. Help for this is in the "eval()" help file.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.