Hey all,
I need to remove parts of a movieclip name for an application I’m developing. In this application, clicking on one of the movieclips will trace out its name (and eventually pass the name to another function as an argument). When I click on the MC, it will trace out as “I clicked _level0.mcName”. That’s fine for now, but when I have to pass the mcName to another function, I will have to get rid of the _level0 part on the front. Can anyone help me with that?
Here’s my code:
var teaArray:Array = new Array(); // holds all tea names and benefits
var teaMovieClips:Array = new Array(); // array to hold the names of the tea MCs
// Each tea gets its own array to hold the names of the benefits.
lemongrassArray = new Array("choice1", "choice2", "choice3");
chamomileArray = new Array("choice1", "choice2");
// Push each tea's array into teaArray, which will store everything
teaArray.push({teaName: "Lemongrass", teaBenefits: lemongrassArray});
teaArray.push({teaName: "Chamomile", teaBenefits: chamomileArray});
// For loop to give each teaName a blue-colored rectangle-shaped MC
for (var i:Number = 0; i < teaArray.length; i++) {
teaMovieClips* = attachMovie("mcTea", teaArray*.teaName, _root.getNextHighestDepth());
teaMovieClips*._x = Math.floor(Math.random() * (550-1));
teaMovieClips*._y = 100 + Math.floor(Math.random() * (400 - 101));
teaMovieClips*.txtTeaName.text = teaArray*.teaName;
teaMovieClips*.onRelease = function() {
trace("I clicked " + this);
};
};
And my trace statement:
I clicked _level0.Chamomile
I clicked _level0.Lemongrass
And here is a link to my FLA file if you want to download and try it out.
Thanks a lot!