http://jacksondunstan.com/articles/1642 I followed this to the T, yet I'm running into issues. I'm trying to save a bunch of icons. They have a custom class "Iconn" and are stored in a Vector.<Iconn>
for future use. Once the user adds a new icon, I open up a filestream and use it to write the entire vector.
public function addShortcut(f:File):void
{
//Display on side
icons.reverse(); //Add to the front so it displays on the top.
icons.push(new Iconn(f)); //Use 16x16 bitmap
addChild(icons[icons.length - 1]);
icons.reverse();
//Save object
fs = new FileStream();
fs.open(shortcuts, FileMode.WRITE);
fs.writeObject(icons);
fs.close();
reorder(); //Reorganizes the icons on the screen.
}
This works all and well with no errors, but when I try to re-launch the application with some icons saved, the vector doesn't even exist.
icons = new Vector.<Iconn>();
if (shortcuts.exists)
{
trace("Shortcuts exist..adding");
fs = new FileStream();
fs.open(shortcuts, FileMode.READ);
icons = fs.readObject() as Vector.<Iconn>;
fs.close();
trace("icons = " + icons); //TypeError: Error #1009: Cannot access a property or method of a null object reference.
trace("icons length = " + icons.length); //TypeError: Error #1009: Cannot access a property or method of a null object reference.
}
I tried adding registerClassAlias("Vector.<Iconn>", Vector.<Iconn>);
, but then I get a compiler error
1067: Implicit coercion of a value of type __AS3__.vec:Vector.<Iconn> to an unrelated type Class
.
Edit: Here is my Iconn class http://pastebin.com/5TujzpvR