2 Replies Latest reply on Nov 8, 2007 6:12 AM by Greg Dove

    Array syntax

    vorpal Level 1

      time ago I used
      myArray = []
      to define a new Array()

      seems to me it would work like :
      var myArray:Array = new Array()

      But it doesn t since when I convert
      myArray = []
      var myArray:Array = new Array()
      my old script doesn't work anymore

      Any explanation?
        • 1. Re: Array syntax, old and new
          kglad Adobe Community Professional & MVP
          there's no difference between



          new Array()

          there is a difference if you prefix your variable with var when in a function body: the variable is then local to the function body.
          • 2. Array syntax, old and new
            Greg Dove Level 4
            there's another difference there:

            you're using var the second time which declares it as a local variable. So it limits the scope of myArray's use - e.g. perhaps inside a function. Perhaps that's the problem. If it is just make sure you declare it in the scope that it will be used from.

            oops kglad beat me to it!