7 Replies Latest reply on Aug 27, 2007 11:43 AM by clbeech

    Noob Question about string and Movie Clip symbols

      So I have an array that has the instance names of some movie clip symbols.... I want to grab one at random and perform operations on it.

      So I set an array with the string names and grab one at random.

      var log_array:Array = ['truckStop_mc', 'blackJack_mc'];
      var index:Number = Math.round(Math.random() * log_array.length);

      I then used trace to make sure that I am grabbing the name correctly..... it is returning me the names...


      I then try to set the x and y property

      log_array[index].x = 399.4;
      log_array[index].y = -3;

      I get this error at runtime:
      Cannot create property x on String

      I tried storing just the clips themselves as objects but that errored as well.

      var log_array:Array = [truckStop_mc, blackJack_mc];

      Is there a way to store the objects themselves in the array or is there a way of converting that string to the object....

      Something like
      var obj:Object = getObject(log_array[index]);
      obj.x = .......

      any help would be great... I have been stuck for a bit now.