2 Replies Latest reply on Jun 15, 2009 5:43 AM by David Beedle

    Revisiting: Referencing a MovieClip using a variable

    David Beedle

      This is a problem I thought I understood and was addressed in a previous thread (http://forums.adobe.com/thread/441458?tstart=0), but I have a new situation where the old solution isn't working.

       

      I have 3 instances on a "nested" movie clip. Their instance names are: b1, b2, and b3. When I trace these movieclips from the main timeline, I get:

       

      trace(b1); // result = _level0.slide_mc.newMC.b1

      trace(b2); // result = _level0.slide_mc.newMC.b2

      trace(b2); // result = _level0.slide_mc.newMC.b3

       

      From the main timeline, I want to fade up these movieclips using tween, but I need to do this by building the instance name in a variable:

           var myInstance:String = "slide_mc.newMC.b"+ instanceNumber //(instanceNumber is equal to 1, 2, or 3)

       

      Now, I thought using the variable in this manner would work:

           new Tween (this[myInstance], "_alpha", None.easeNone, 0, 100, .5, true);

       

      ...but it doesn't.

       

      I've checked trying to use the actual movie clip instance:

           new Tween (this.slide_mc.newMC.b1, "_alpha", None.easeNone, 0, 100, .5, true);

       

      ...and it works fine. What am I not getting here?

       

      Thanks.