3 Replies Latest reply on Jul 31, 2007 1:14 PM by kglad

    Array syntax AS 2.0

    MATTANDIE Level 1
      Hello,

      I have been going through the tutorials in Adobe's Flash 8 training from the source, and I have run into a syntax question about arrays and was hoping someone could explain something for me.

      specifically why I can trace an element in the first example but not in the second. (IE. why does the second format not work and what do i need to do to make it work.

      ex1.

      var directory:Array = [{name:"John", phone:"919-555-5698"}, {name:"Kelly", phone:"232-555-3333"}, {name:"Ross", phone:"434-555-5655"}];

      In this example I can run a trace to any item in the array.


      ex 2.

      var directory = new Array();

      directory[0].Name = "John"
      directory[0].Phone = "919-555-5698"

      directory[1].Name = "Kelly"
      directory[1].Phone = "232-555-3333"

      directory[2].Name = "Ross"
      directory[2].Phone = "434-555-5655"

      all traces come up as undefined.

      I have used the second examples format before with very few problems, so any insight to this would be greatly appreciated.


      Thanks.