my interests and experiences
RSS icon Email icon Home icon
  • AS3 – how to do eval() the right way

    In AS2 we used to be able to refer to an instance name of an object by coding:


    This would allow you to create and/or refer to instance names using a string. I have heard quite a bit of negativity about eval() but it did come in handy at times. In AS2, you could also use:


    which worked well for me when pushing items to an array, before AS3 was available.

    Now, the correct AS3 way to do it is either this:

    this["my_mc" + i];


    this.getChildByName("my_mc" + i);

    I would recommend the second way of doing it, because to me it just makes more sense.