Very interesting. Not exactly what I wanted but I guess that's what I will have to work with in AS.
I was hoping I could just return WeakReferences that would resolve to the type it is referencing, but for that I guess we need support from the VM. So seamless in Java. So for me to implement a cache using WeakReferences I will need to change my dataDescriptors, and everywhere I access my Objects to call getObject(). I will have to read up more on managing object caches in AS, not sure if this is the best strategy in AS. Many thanks Manish! -Greg On Tue, Feb 3, 2009 at 3:33 PM, Manish Jethani <[email protected]> wrote: > On Tue, Feb 3, 2009 at 11:11 PM, Greg Hess <[email protected]> wrote: >> >> Objects are all passed by reference, I want to pass a weak reference >> back to callers who request items from the cache, much like the >> internal implementation must do in some way when >> addEventListener(...true) as a weak reference. >> >> For example: >> >> public function getItem( id:String ):Item >> { >> var item:Item = getItemFromCache(id); >> return new WeakReference( item ); >> } >> >> So that anyone who has obtained an item from cache will not prevent >> the object from being garbage collected. > > > http://manishjethani.com/blog/2008/07/31/using-weak-references-in-actionscript-3/ > Manish >

