0

What I want? Save my Project in a Editor created with Air Application

What is to save? 1 Object -> Type ArrayCollection -> Contains -> Objects from own classes...

What was my first try?

var stream :FileStream = new FileStream();
stream.writeObject(myArrayCollection);

What was the Problem? The objects inside of myArrayCollection got this Structure:

public class MyClass1
    {
        public var title:String;
        public var description:String;
        public var kindOf:String = "...";
        public var thumbnail:String;
        public var children:ArrayCollection
...}

Every public var were saved by the FileStream.... works fine Inside the children arrayCollection are objects from this class:

public class MyClass2 extends XMLDocument implements IExternalizable
    {

        public const kindOf:String = "Seite";

        [Bindable]
        public var title:String;
        public var contenBox:OwnClass; //extended spark Group

public function get childrens():ArrayCollection
        {
            var childs: ArrayCollection = new ArrayCollection();

            var i:int = 0;
            while(i > (contenBox.container as spark.components.Group).numElements)
            {
                childs.addItem((contenBox.container as spark.components.Group).getElementAt(i));
                i--;
            }

            return childs;
        }

        public function readExternal(input:IDataInput):void
        {
            trace("hello i'am reading");
        }

        public function writeExternal(output:IDataOutput):void
        {
            trace("hello i'am writing");
            output.writeObject(children);
        }

Now the Problem... the fileStream contains my MyClass2 objects with the var "title" but there is no children ArrayCollection... the console don't shows the traces :-/

Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46

1 Answers1

1

Have you tried serializing your Object? You could serialize it to XML and than back again on reading. It seems a good library for this is Flexxb

other way would to write the file as raw binaries with Bytearray as was explained here

hope it helps!

Community
  • 1
  • 1
brubs
  • 1,259
  • 8
  • 23