Question
Troubles with dynamic references
I'm having difficulty with something that I feel should be
trivial.
I have a bit of code where I want to loop through a variable and add a new empty movie clip, each with a uniquie name and then reference that new clip to load a movie. In the example below myMC is a parent movie clip that I want to create the new sub-clips in.
Something along these lines:
for(i=0; i<5; i++)
{
clip = "prefix"+i;
myMC.createEmptyMovieClip(clip, getNextHighestDepth());
var ref = eval(clip);
myMC.ref.loadMovie("movie to load");
}
I must be missing something very obvious here because this doesn't work. How can I actually get the object reference for the newly created movie? When I debug this movie the ref variable remains undefined.
I have a bit of code where I want to loop through a variable and add a new empty movie clip, each with a uniquie name and then reference that new clip to load a movie. In the example below myMC is a parent movie clip that I want to create the new sub-clips in.
Something along these lines:
for(i=0; i<5; i++)
{
clip = "prefix"+i;
myMC.createEmptyMovieClip(clip, getNextHighestDepth());
var ref = eval(clip);
myMC.ref.loadMovie("movie to load");
}
I must be missing something very obvious here because this doesn't work. How can I actually get the object reference for the newly created movie? When I debug this movie the ref variable remains undefined.