1 Reply Latest reply on Apr 2, 2007 7:23 AM by kglad

    Error in simple Tutorial? With(object) gives undifined..

    chrisatflash Level 1
      Hello, I got this from an tutorial, but when i run this
      the
      trace(person1.address.street);
      gives undifined ? How come this is undifined and
      trace(person1.address.test);
      is not? ..looks like the With( ...) does not work?

      here is the script:

      person1 = new Object();
      person1.address = new Object();

      person1.address.test = "hello";

      with(person1.address) {
      street = "123 Main Street";
      city = "Boston";
      state = "MA";
      zip = "02114"; }


      trace(person1.address.street);
      trace(person1.address.test);
        • 1. Re: Error in simple Tutorial? With(object) gives undifined..
          kglad Adobe Community Professional & MVP
          "To set a variable inside a with statement, you must have declared the variable outside the with statement, or you must enter the full path to the Timeline on which you want the variable to live. If you set a variable in a with statement without declaring it, the with statement will look for the value according to the scope chain. If the variable doesn't already exist, the new value will be set on the Timeline from which the with statement was called."

          ie, street is defined on the timeline that contains that code.