For the Dunelox library, I needed a simplified Flex version of the Spring ApplicationContext which is a generic Hash object containing model objects accessed by a key (String). Visual components that are wired to these models objects need to be updated automatically using the standard event mechanism in Flex.
So, I had a look at the standard ArrayCollection to find out how it notifies components that are wired to elements by index. This gave me the idea to implement the HashCollection as a extension to this class.
If you need to wire a value by key in a component such as:
<mx:TextInput text=”{hash.get(’somekey’)}” />
And you declare the variable hash as a HashCollection like this:
[Bindable]
public var hash:HashCollection = new HashCollection()
Then your component is updated if you change the value associated to that key:
hash.put(’somekey’, ‘changed the value of somekey’ )
——–
Update: have a look at the source code
Feedshot
I guess I am not the only person who has had to deal with the flex hash map collection silliness. You should take a look at this post which details many different hash mapping solutions that are available.
http://michaelangela.wordpress.com/2008/04/11/cairngorm-factories-for-xml-in-and-vo-out/
Regards,
Derek Basch
Comment by Derek Basch — May 8, 2008 @ 4:36 am |