A reference to an object through it's idField will fail to yield the cached object if the member is defined in the class as a base-type of the cached object.
Consider this XML:
<storyNodes>
<storyNode id="1">
Blah blah blah
</storyNode >
<storyNode id="2">
Dum dee dum dee doo
</storyNode >
</storyNodes>
<connections>
<connection id="3">
<secondNode id="1"/>
<firstNode id="2"/>
</connection>
</connections>
The storyNode elements represent instances of the StoryNode class which extends Node.
[...]
public class StoryNode extends Node
The connection elements represent instances of Connection class.
[...]
public class Connection
{
[XmlElement(serializePartialElement="true", getFromCache ="true")]
public var firstNode:Node;
[XmlElement(serializePartialElement="true", getFromCache ="true")]
public var secondNode:Node;
...
When you deserialize the XML the Connection object's firstNode and secondNode fields do not reference the StoryNode objects in the cache.
I made a non-elegant workaround for this... In the ObjectCache.isInCache and ObjectCache.getFromCache methods I added the following code.
if (!(clasz in cacheMap)) {
for (var t:Object in cacheMap) {
if ((t as Class).prototype instanceof clasz) {
clasz = t as Class;
break;
}
}
}