1

I've a general question on accessing a MovieClip by using a variable.

Here's a super stripped down version of the code I'm trying to implement:

var mcVar:String = MC1;

addEventListener(Event.ENTER_FRAME, eF);
function eF(e:Event):void{  
   if (BGMov.[mcVar].currentFrame >= 10){       
      BGMov.gotoAndStop(2);     
   }
}

Is this a possibility? Any help is greatly appreciated! Cheers, Simon

Simon
  • 11
  • 2

1 Answers1

2

Try this:

var mcVar:String = "MC1";

addEventListener(Event.ENTER_FRAME, eF);
function eF(e:Event):void{  
    if (BGMov[mcVar].currentFrame >= 10){       
        BGMov.gotoAndStop(2);     
    }
}

I believe you just need to make sure mcVar is a string and there is no dot before the square bracket. However this is untested as I haven't got Flash open right now.

David Hancock
  • 14,861
  • 4
  • 41
  • 44