7 Replies Latest reply on Jun 26, 2006 12:15 PM by Andreq85

    targetting a movie clip

    Level 7
      I''m trying to target seceral movie clips (BAR1,BAR2,BAR� etc) from within
      an object.

      If I use BAR1._xscale=50 it works fine

      BUT, i need to use the array assignment operator (i think that's the right
      term) to loop through all of them

      this["BAR"+n]._xscale does not work because it's not in the object

      _parent["BAR"+n] does not work because BAR1 is not in the parent.

      n is a counter

      How do I change the syntax to make this work?

      Many thanks

      Dave


        • 1. Re: targetting a movie clip
          squipple Level 1
          If you're just straight referencing an array, you'd reference it like:
          BAR[n]

          If you're looping through, say, a for loop, then you should be using
          this["BAR"+n]
          • 2. Re: targetting a movie clip
            Level 7
            but i can't use "this", because the code is within an object and the movie
            clips are not

            "squipple" <webforumsuser@macromedia.com> wrote in message
            news:e7p5iv$r1o$1@forums.macromedia.com...
            > If you're just straight referencing an array, you'd reference it like:
            > BAR[n]
            >
            > If you're looping through, say, a for loop, then you should be using
            > this["BAR"+n]


            • 3. Re: targetting a movie clip
              Andreq85
              if actualy your BAR1 is not from this or _parent.. then : ["BAR"+n]._something should work..
              • 4. Re: targetting a movie clip
                squipple Level 1
                Sorry dave, I must not know enough about what you're doing to help. If you're trying to reference something within an object, then add that:

                myobject["BAR"+n]._width

                Andreq85: you can't start a line with brackets, you need a level or location reference preceeding it.
                • 5. Re: targetting a movie clip
                  Andreq85 Level 1
                  actualy.. in the old time (flash 5 i think) you could do it.. but Ive never had to do it without a this or someObejct["someting"+n] ... but for sure your BAR somthing is inside another object... if you are creating them dynamicly you could push them in an array like
                  myNewObject = BAR1 = new Object
                  myArray.push(myNewObject)

                  then you loop trought the array and myArray[n] will be the Object ref..
                  • 6. Re: targetting a movie clip
                    Level 7
                    Thanks fro your reply.

                    The code is within an object but the bars are not within that object, they
                    are in the same level.

                    If I use _parent it goes up too far, I just need to go sort of sideways.

                    "squipple" <webforumsuser@macromedia.com> wrote in message
                    news:e7p8l7$1gc$1@forums.macromedia.com...
                    > Sorry dave, I must not know enough about what you're doing to help. If
                    > you're
                    > trying to reference something within an object, then add that:
                    >
                    > myobject["BAR"+n]._width
                    >
                    > Andreq85: you can't start a line with brackets, you need a level or
                    > location
                    > reference preceeding it.
                    >


                    • 7. Re: targetting a movie clip
                      Andreq85 Level 1
                      hooo... I think tis could work

                      this._parent["BAR"+n]

                      otherwise if you can post your BAR1 generation code it would help a bit