I noticed in the archives that Gordon kindly offered the class below.

However, I believe the obvious limitation is that binding will fire for all
keys each time that put() is called for one key.

Has anyone developed a more sophisticated version in the interim, that is as
efficient as separate properties?

Thanks!

package
{

import flash.events.Event;
import flash.events.EventDispatcher;
import flash.utils.Dictionary;

public class BindableDictionary extends EventDispatcher
{
    public function BindableDictionary()
    {
        super();
    }

    private var dictionary:Dictionary = new Dictionary();

    [Bindable("change")]
    public function get(key:Object):Object
    {
        return dictionary[key];
    }

    public function put(key:Object, value:Object):void
    {
        dictionary[key] = value;
        dispatchEvent(new Event(Event.CHANGE));
    }
}

}

Reply via email to