7 Replies Latest reply on Jan 21, 2007 11:34 AM by kglad

    Instance Name as a Variable

    supshur
      This is probably an easy problem to solve for those with more than a months experience with flash.

      I have a movie clip that will have many instances of itself. Contained in this "Master" Movie clip there is a dynamic text box that needs to state it's <instance name>. So that each time I drop this "Master" Movie clip onto the main timeline all I have to do to get each new instance's text to change is to change the <instance name> box itself.

      I tried setting the dynamic text's VAR to the <Instance Name> but I don't know what the code for the "<Instance Name>" is or if that is even the right way to approach it.

      any thoughts?
        • 1. Re: Instance Name as a Variable
          kglad Adobe Community Professional & MVP
          if you mean you want the textfield to display its path/instance name (and not the movieclips path/instance name), then on the timeline of your master movieclip you can use:

          • 2. Re: Instance Name as a Variable
            supshur Level 1
            I guess, I need to name each duplicate of the "Master Movie" and, when played, have the text box in each of these duplicate movies show the name of that particular duplicate movie. I tried to create a variable in the "Mater Clip's" dynamic text box and then, in the "Master clip's" frame where the text would apear, I tried to get my new variable to = "whatever I put into the <instance name> box" , but I don't know what the program code for the <instance name> box is, or if their is one.

            thoughts.
            • 3. Re: Instance Name as a Variable
              kglad Adobe Community Professional & MVP
              you must name each duplicate if you're using actionscript to duplicate your movieclips or, if you duplicate in the authoring environment, flash will assign an instance name for the duplicates if you fail to do so.

              to display the name of the moviecip (instead of the textfield's name) use:

              • 4. Re: Instance Name as a Variable
                supshur Level 1
                Ok, so it worked!
                I used " tf.text=this._name "
                ...I substituted " MyDynamicText'sInstanceName " for " tf ".

                However, I needed to redo some things and tried the process again, except this time none of the codes seem to work. The only time the text on my duplicate movies change on the master time line from the phrase actually written in the Master dynamic text box, is when I put the same name into both the <Instance Name> box and the Variable box in the master dynamic Text Properties Panel. The text displayed by the duplicate would then only show the enitre duplicate's path.

                I don't know if there is an important workflow or _parent relationship that might have been overlooked or disordered by the rebuild process.

                thoughts?
                • 5. Re: Instance Name as a Variable
                  kglad Adobe Community Professional & MVP
                  you have one movieclip in your library and that movieclip contains one textfield, correct?

                  if so, then you only need one line of code on that movieclip's timeline to force all the textfields in all your movieclip instances to be populated by the instance name of the movieclip.
                  • 6. Re: Instance Name as a Variable
                    supshur Level 1
                    Works Great! Thanks for the Help kglad!!
                    --supshur
                    • 7. Re: Instance Name as a Variable
                      kglad Adobe Community Professional & MVP
                      you're welcome.