Note that there are some explanatory texts on larger screens.

plurals
  1. POType preservation failing with RemoteClass
    primarykey
    data
    text
    <p>Consider the following example dataclass:</p> <pre><code>[RemoteClass] public class SOTestData { public var i:int; public function SOTestData(i:int) { this.i = i; } } </code></pre> <p>As I understand, the RemoteClass metadata-tag should ensure that when an object of this class gets sreialized, the type information is preserved. </p> <p>I used the following program to test:</p> <pre><code>public class SOTest extends Sprite { public function SOTest() { var data:SharedObject = SharedObject.getLocal("SOTest"); if (data.data.object) { try { var stored:SOTestData = data.data.object; trace(stored.i); } finally { data.clear(); } } else { data.data.object = new SOTestData(15); data.flush(); } } } </code></pre> <p>Here the first run writes the data, seconds reads and clears. Running this, I still get a class cast error. Indeed, in the SharedObject there is no type information stored.</p> <p>I don't think i'm using the metadata wrong, could it maybe be that the compiler doesn't know what to do with it? I don't get any compiler errors/warnings, although when i use some inexistant tag it doesn't complain either. I'm using Flex 4.6 SDK with FlashDevelop as IDE.</p> <p><strong>EDIT:</strong></p> <p>Below is the shared object. As you can see, the type is saved as "Object" instead of the actual type.</p> <pre><code>so = [object #2, class 'SharedObject'] { data: [object #0, class 'Object'] { object: [object #1, class 'Object', dynamic 'False', externalizable 'False'] { i: 15, }, } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload