3 Replies Latest reply on Aug 11, 2009 11:06 AM by Ned Murphy

    VAR instead of instance names

    Ron Colmen Level 2

      How to write the following AS codes using VAR instead of instance names?

       

      my_Input_Txt.onChanged = function() {   
      _root.my_Dyn_Txt5.text = my_Input_Txt.text;
      _root.my_Dyn_Txt6.text = my_Input_Txt.text;
      };

       

       

      _root.my_Dyn_Txt5._visible = false
      _root.my_Dyn_Txt6._visible = false
      _root.MDT1._visible = false
      grt1._visible = false
      this.chk_tbtn1.onRelease = function() {
      _root.my_Dyn_Txt5._visible = !_root.my_Dyn_Txt5._visible;
      _root.my_Dyn_Txt6._visible = !_root.my_Dyn_Txt6._visible;
      _root.MDT1._visible = !_root.MDT1._visible;
      grt1._visible = !grt1._visible;
      };

       

       

      on (press) {
      this._parent.rotate_mc1._xscale += 7;

      }

        • 1. Re: VAR instead of instance names
          Ned Murphy Adobe Community Professional & MVP

          You'll have to explain what you mean and what you are trying to do.  A var essentially defines a new instance, so if you are dealing with existing instances, which appears to be the case, then using var is inappropriate except to define new instances that refer to / target existing ones, in which case you are still dealing with instance names.

          1 person found this helpful
          • 2. Re: VAR instead of instance names
            Ron Colmen Level 2

            What's the difference between having an INSTANCE name and having a VARIABLE name? What is the best choice to use when writing AS codes?

            • 3. Re: VAR instead of instance names
              Ned Murphy Adobe Community Professional & MVP

              I am probably not the best person to get into this bit of semantics, so anyone that has a more technically correct explanation is welcome.  In my view there is little difference, but if you need to write code, then using one or the other is usually dictated by the status of something's existence...

               

              If you need to create something with code, chances are you will be using the var approach.  But if you are referring to an object that already exists, then you will be using the instance name of the object to address it, because the use of the term "var" essentially creates new instances of things.

              1 person found this helpful