I have a UIComponent (let's call it Foo) that extends Canvas. I'm trying
to track various instances of this in an Object, mapping each instance
to some String metadata. However, when I re-parent a Foo instance (by
adding it to a new container), or I re-parent that parent container, it
seems to be treated as a completely distinct key by the Object. For
example

var map:Object = new Object();

var foo:Foo = new Foo();

map[foo] = "foo";
for (var key:* in map) {
   // Output is something like 'key is Foo455'
   trace("key is " + key);
}
var bar:Bar = new Bar();
bar.addChild(foo);

map[foo] = "re-parented foo"
for (var key:* in map) {
   // Output is something like 'key is Foo455', 'key is Bar211.Foo455'
   trace("key is " + key);
}

Am I missing something? It seems like putting a reference to the object
in a map should not changed when that object is re-parented. Is there
any way to do what I'm looking for? What's the reasoning behind this
behavior.


-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com


Reply via email to