What's the trick to inheriting from a Dictionary in AS3?
actionscript-3, apache-flex, dictionary, inheritance
Solution
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);
}
}
}
Problem
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!