0

I am trying to migrate as2 to as3 code. The normal solution to my problem involves using the first parameter of the createEmptyMovieClip() as the name of your movie clip. In several instances I have a dynamic value for this first parameter- so my question is How should I go about doing this?

//my code  
 function someFunction (){
    loader_mc = this.createEmptyMovieClip("text"+value, value);
    value++;
    //do stuff with it
}

//normal non-dynamic solution 
function someFunction (){
    var text:MovieClip = new MovieClip();
    addChild(text);
    //do stuff with it
}
woodlumhoodlum
  • 462
  • 3
  • 10
  • 24

1 Answers1

2

In your question, you're already saving a direct reference to the MovieClip. If that's the only reference you need to do your work, then you really don't need to give the MovieClip a name.

If you do need the name, though, you can always assign the MovieClip a name after the fact:

var myClip:MovieClip = new MovieClip();
myClip.name = "text"+value;

parent.addChild(myClip);

This will let you use the getChildByName method:

parent.getChildByName("text"+value);
meddlingwithfire
  • 1,437
  • 8
  • 12