3 Replies Latest reply on Nov 17, 2006 1:58 PM by GentleG

    mc instance name as variable?

    GentleG
      Hi all

      I know how to create empty movieclips that I name (instance) using the content of an array (with text)
      But I don't know how to refer to them without typing in the name manually.

      array (
      one ,1
      two ,2
      three , 3)

      for i =1 to 3

      createemptymc ( array(i , 0)

      this works

      but if I want later to do something with the mc I cannot do

      array(i,0).alpha=70

      So how would I refer to the created mcs using the same array?

      Thank you
      Cheers
      Geert
        • 1. Re: mc instance name as variable?
          digitellinc
          I don't know if this would be the correct way to do this, but I have used it in some old projects.

          newTarget = eval("_root." + array[i,0] );
          tellTarget("newTarget"){
          alpha = 70;
          }
          • 2. Re: mc instance name as variable?
            Level 7
            I think you have to refer to it as a property of the object that holds it
            using brackets.

            this[array(i,0)].alpha

            Here is an article that explains how to use variable clip names:
            http://www.darknews.com/?p=34

            I hope that helps, I'm sort of a flash noob myself....

            Timm

            "GentleG" <webforumsuser@macromedia.com> wrote in message
            news:ejl08i$o3b$1@forums.macromedia.com...
            > Hi all
            >
            > I know how to create empty movieclips that I name (instance) using the
            > content
            > of an array (with text)
            > But I don't know how to refer to them without typing in the name manually.
            >
            > array (
            > one ,1
            > two ,2
            > three , 3)
            >
            > for i =1 to 3
            >
            > createemptymc ( array(i , 0)
            >
            > this works
            >
            > but if I want later to do something with the mc I cannot do
            >
            > array(i,0).alpha=70
            >
            > So how would I refer to the created mcs using the same array?
            >
            > Thank you
            > Cheers
            > Geert
            >
            >


            • 3. Re: mc instance name as variable?
              GentleG Level 1
              thank you very much

              this will save me hundreds of lines of code :)

              Cheers