PDA

View Full Version : Load an array of custom objects from a shared object



contrast
March 5th, 2008, 12:02 PM
I have an array of Widgets (a class I created) called "widgetArray" that I save into a shared object.

savedGame1.data.widgetArray = widgetArray;

When I go to load this data out and use the widgets I run into problems. The array is stored fine, but each widget is saved as an object. So I can't simply do:

widetArray = savedGame1.data.widgetArray;

because then if I try to use the widgets:

widgetArray[0].someWidgetFunction();

it does not work because flash thinks they are objects. I have tried typecasting the widgets when I load them, but it only produces a null object.

widgetArray[i] = widgetArray[i] as Widget;//widgetArray[i] becomes null
tempWidget:Widget = widgetArray[i] as Widget;//null as well

How does anyone else deal with this?