Hello. Without writing a crazy amount of code I am trying to compare 2 arrays and attach the appropriate movieclip when a menu item is pressed. Overall there are 22 items in both arrays. The first, cityArray is a list of 22 cities and the subMenuArray is an address list that needs to match up to the appropriate city. The goal here is that when any of the menu items are pressed the correct sub menu item (stored in the library) is attached. I suppose there is an easier way to to write this (scroll down to red text) than the below code but I don’t really know how. Any help you can offer is greatly appreciated.
stop();
// create movie clipnames that mirror what is placed on the stacge
var nameArray:Array = new Array();
var cityArray:Array = new Array();
var subMenuArray:Array = new Array();
for (var i:Number = 0; i<22; i++) {
var cityNumber:Number = i+1;
cityArray.push(“city”+cityNumber);
}
//flip city menu animation
for (i=0; i<cityArray.length; i++) {
_parent.menu1[cityArray*].sniffer.onRollOver = function() {
this._parent.gotoAndPlay(“btnStart”);
updateAfterEvent();
};
_parent.menu1[cityArray*].sniffer.onRollOut = function() {
this._parent.gotoAndPlay(“backward”);
updateAfterEvent();
};
}
// create movie clipnames that mirror city names in library and then
//import from library corresponding moviclips
for (var i:Number = 0; i<22; i++) {
var subNumber:Number = i+1;
var nameNumber:Number = i+1;
subMenuArray.push(“subMenu”+subNumber);
nameArray.push(“cityName”+nameNumber);
this.attachMovie(nameArray*, nameArray*+“n”, getNextHighestDepth());
//attach the container clip
//establish x and y postion for all text movie clips relative to the backgrounds of the main menu
this[nameArray*+“n”]._y = this[cityArray*]._y-35;
this[nameArray*+“n”]._x = this[cityArray*]._x-75;
[COLOR=darkred]// this is the part I can’t get to work the way I want[/COLOR]
// Attach submenu to main menu based on y position of the corresponding city
}
_parent.menu1[cityArray[0]].sniffer.onPress = function() {
attachMovie(subMenuArray[0], subMenuArray[0]+“n”, getNextHighestDepth());
subMenu1n._x = 200;
//this[cityArray*+“n”]= this[subMenuArray*+“n”]
};
_parent.menu1[cityArray[1]].sniffer.onPress = function() {
attachMovie(subMenuArray[1], subMenuArray[1]+“n”, getNextHighestDepth());
subMenu2n._x = 200;
//this[cityArray*+“n”]= this[subMenuArray*+“n”]
};