1 Reply Latest reply on Feb 5, 2010 3:43 AM by invisibleBlade

    Can I reference static class vars via a string?

    invisibleBlade

      Hi all,

      I am trying to set the value of some static vars but I need to reference the class with a string rather than a proper constructor. In AS3 I can do this with:

      var ref:Class = getDefinitionByName(classDefinitionAsString) as Class;

      ref[varNameAsString] = newValue;

       

      I can't find an equivelant approach that will work in AS2 though. I have tried:

      var ref:Object = new [classDefinitionAsString];

      ref[varNameAsString] = newValue;

      This seems to just create an Object and as the vars that I am trying to access are static I don't really want to be using 'new' I just want to reference the vars.

      Is this even possible in AS2 and if so can anyone explain how I might do this?

       

      Cheers for any help