2 Replies Latest reply on Sep 15, 2009 6:08 AM by joetopshot

    Strange problem with flash.utils.Dictionary

    joetopshot

      I'm having problems working with an AS class that extends Dictionary. Here's a small code snippet that represents my problem:

       

      package
      {
          import flash.utils.Dictionary;


          public class DI extends Dictionary
          {
              public function DI(weakKeys:Boolean=false)
              {
                  super(weakKeys);
              }
             
              public function setStuff():void
              {
                  var d:Dictionary = new Dictionary();
                  var key:String = "CreationClassName";
                  var val:String = "D13BCOR1";
                  d[key] = val;
                  this[key] = val;
                  trace("key/val=" + val);
              }
             
          }
      }

       

      Note that the line

      d[key] = val;

      works just fine.  However, the next line

      this[key] = val;

      gives me a runtime error:

      ReferenceError: Error #1056: Cannot create property CreationClassName on DI.
          at DI/setStuff()[C:\jberry\workspaces\rnx\ActionScriptTest\DI.as:18]
          at ActionScriptTest()[C:\jberry\workspaces\rnx\ActionScriptTest\ActionScriptTest.as:9]

       

      Is there a different syntax than what I am using for setting a key/value combo for a class that extends Dictionary?

       

      FYI, the code that calls the above looks like this:

              public function ActionScriptTest()
              {
                  var di:DI = new DI();
                  di.setStuff();
              }

       

      Thanks in advance for any hints/suggestions.

       

      Joe