2 Replies Latest reply on Feb 14, 2007 4:55 AM by Newsgroup_User

    variable name

    Level 7
      hi,
      I want to know difference between instance name & variable name.


        • 1. Re: variable name
          Dave.Hollings
          This comes from FLASH MX 2004 help files:

          Instance names are unique names that let you target instances you create, or movie clip and button instances on the Stage. For example, in the following code, “names” and “studentName” are instance names for two objects, an array and a string:

          var names:Array = new Array();
          var studentName:String = new String();

          You use the Property inspector to assign instance names to instances on the Stage. For example, a master symbol in the library could be called counter and the two instances of that symbol in the SWF file could have the instance names scorePlayer1_mc and scorePlayer2_mc. The following code sets a variable called score inside each movie clip instance by using instance names:

          this.scorePlayer1_mc.score = 0;
          this.scorePlayer2_mc.score = 0;

          Variables are identifiers that hold values of any data type. Variables can be created, changed, and updated. The values they store can be retrieved for use in scripts. In the following example, the identifiers on the left side of the equal signs are variables:

          var x:Number = 5;
          var name:String = "Lolo";
          var c_color:Color = new Color(mcinstanceName);

          • 2. Re: variable name
            Level 7
            > code, ?names? and ?studentName? are instance names for two objects, an
            > array
            > and a string:
            > var names:Array = new Array();
            > var studentName:String = new String();

            No .. they are variable names .. not instance names.

            The difference is that an instance has a name of its own. Eg if you place
            an movieclip on the screen you can give it a name.. That is its instance
            name. In script you can use the instance name (ie that name you give an
            instance on stage, or when you dynamically create it) in the same way as you
            can a variable or property. (ie in script, an instance name looks like a
            variable name)