3

Given the following code:

import flash.utils.Dictionary;

import mx.collections.ArrayCollection;
import mx.controls.Alert;

public class CDictionary extends Dictionary
{
    public function CDictionary(weakKeys:Boolean=false)
    {
        super(weakKeys);
    }
}

this raises Error #1056:

m_cdictNearIDs = new CDictionary();
m_cdictNearIDs[4] = "f";

but this doesn't:

m_cdictNearIDs = new Dictionary();
m_cdictNearIDs[4] = "f";

(In each case, it's a member variable that's declared to be of the same type it's instantiated as.) Wth? What's the trick to inheriting from dictionary? Thanks!

Panzercrisis
  • 4,590
  • 6
  • 46
  • 85

1 Answers1

6

You must define your class as dynamic:

package
{
    import flash.utils.Dictionary;

    public dynamic class CDictionary extends Dictionary
    {
        public function CDictionary(weakKeys:Boolean=false)
        {
            super(weakKeys);
        }
    }
}
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80