2 Replies Latest reply on Feb 15, 2007 10:53 AM by TheBorg[NL]

    [AS3] Access library object by variable name

    TheBorg[NL]
      Let's say I have a button which sets the variable color to green:

      var color:String = "green"

      I have a movieclip in my library called "green". With AS2 we could simply use:
      whatever.attachMovie(color, "someclip", 1);

      In AS3 this works perfectly fine:
      var whatever:Sprite = new green ();

      to use the variable I tried the following:
      var whatever:Sprite = new this[color] ();

      but the movieclip is not loaded. Any ideas?