1 Reply Latest reply on Jan 8, 2010 10:02 AM by pauland

    ho do i programmatically reference components?

    rkhpld

      In AS2 I could use eval(), in php i could use varvar ($$foo), but can't figure out how to achieve this in AS3.

       

      I have a handful of custom components in a parent component (let's call it parentComp for this example).  I want to be able to reference them programmatically like this:

       

      var someDynamicName:String='foo';

      parentComp[someDynamicName].doSomething();

       

      in this example above, I hope to reference the custom component named 'foo' inside the 'parentComp' parent component.

       

      i've tried a bunch of different syntaxes like parentComp.someDynamicName.doSomething();,etc...

       

      i also read about creating an object that holds all the custom components like,

       

      var compHolder:Object={obj1:'foo',obj2:'bar'};

       

      but then compHolder['obj1'].doSomething(); doesn't affect the custom component 'foo' at all.

       

      Any help would be much appreciated, thank you.