1 Reply Latest reply on Jul 14, 2007 2:45 PM by SymTsb

    array declaration fails inside class

    arby10101 Level 1
      When I attempt to run the following code, I get the error:
      1120: Access of undefined property myArray. for lines 4, 5, 6, and 7.
      This code is copied from the Adobe docs and works if placed directly in a timeline frame. Declaring a new Object fails in the same way inside the class. But another top level class new Date works as expected. What am I missing here?
        • 1. Re: array declaration fails inside class
          SymTsb Level 2
          variable declarations are done inside a class definition. variable assignment should be done inside the class' constructor which you are missing....

          package Classes{
          public class TryArray {
          var myArray:Array = new Array();\
          public function TryArray():void{
          myArray.push("one");
          myArray.push("two");
          myArray.push("three");
          trace(myArray);
          }
          }
          }