Referincing dynamic instances

Hi,

Attached is my file, beter to lok at it than try to understand my explanation alone.

I’m using duplicateMovieClip to create instances of a clip. Then I use an array to name the clips. In the scrip that duplicates and names them, I also have an onRelease function to make the mcs do something when you click them. I can’t get this onRelease part to work.

I need to:

  • swap the depths
  • load some text
  • attach a movie from the library

I can’t see any errors with my script, so I hope someone can look at it and give me a clue. The part I’m having trouble with is:
[AS]
screenX = System.capabilities.screenResolutionX;

_root.menuTab._visible = false;

menuItems = new Array();
menuItems[0] = “Cafe”;
menuItems[1] = “Catering”;
menuItems[2] = “Cakes”;
menuItems[3] = “Contact”;
menuItems[4] = “About Us”;
menuItems[5] = “News”;
menuItems[6] = “Lunch”;
menuItems[7] = “Dinner”;
menuItems[8] = “Breakfast”;
menuItems[9] = “Testimonials”;

stageWidth = 700;

k = 0;
do {
duplicateMovieClip(_root.menuTab, “menuItem” + k, k);
k++;
} while (k != _root.menuItems.length);
for(k = 0; k <= _root.menuItems.length; k++){
_root[“menuItem” + k]._x = ((_root.stageWidth/2 + _root.screenX/2) - (_root.screenX/_root.menuItems.length)k - (_root.screenX/_root.menuItems.length)).9;
_root[“menuItem” + k].tab.tabWord = _root.menuItems[k];
//here is where I need help
_root[“menuItem” + k].tab.onRelease = function(){
_root[“menuItem” + k]._level = 100;
loadText.load(“Assets/” + menuItems[k] “.txt”); //You’ll need to create an assets folder with the .txt files in it. The zipped flash file actually has a specific txt file named, but this generic script is what I need.
_root.placeholderSmall.attachMovie(“menuItem” + k, “thumbnails”, 201);
}
}

loadText = new loadVars();
loadText.onLoad = function() {
body_txt.htmlText = this.textField;
}
[/AS]
Thanks for your time.

I think something like this, I’m only not sure if the swapDepth part is what you want:q:
[AS]n = 10;
for (k=0; k<_root.menuItems.length; k++) {
_root[“menuItem”+k]._x = ((_root.stageWidth/2+_root.screenX/2)-(_root.screenX/_root.menuItems.length)k-(_root.screenX/_root.menuItems.length)).9;
_root[“menuItem”+k].tab.tabWord = _root.menuItems[k];
_root[“menuItem”+k].tab.k = k;
_root[“menuItem”+k].tab.onRelease = function() {
this._parent.swapDepths(n);//???
n+=10;
loadText.load(“Assets/” + _root.menuItems[this.k]+".txt ");
_root.placeholderSmall.attachMovie(“menuItem”+this.k, “thumbnails”, 201);
};
}[/AS]

scotty(-: