I posted this a few days ago and am still stuck… I have read a myriad of tutorials on arrays, and still cannot fathom out where I am going wrong … Can anyone help? I have commented the code…
The story is as follows:
I want to be able to create a dynamic list.
In the library I have exported for .as a movie clip given the name “nav”
//The code is as follows:
// [color=blue]I have a couple of arrays[/color]
var buttonNames:Array = ["","Home", "Services", "Advertising", "Become a Driver", "Rates", "FAQ's", "Boston", "AboutUs", "ContactUs"];
var navNames:Array = ["00","01","02","03","04","05","06","07","08","09"];
var currentMenu:Number;
[color=blue]/*there is a 'for loop' that attaches the "nav" movie clip and duplicates, positions etc, depending on the amount of items in the navNames Array. In this loop a function "dopress" is called, when one of the attached movie clips is pressed.*/[/color]
for (var i:Number = 1; i < navNames.length; i++) {
myclip = attachMovie("nav", navNames, i);
myclip._y = 100+(myclip._height+1)*i;
myclip._x = 100;
myclip.myText.text = buttonNames*;
myclip.onPress = dopress;
}
[color=blue]/*The dopress function[/color]
function dopress() {
var menuClip:Number = navNames.length;
for (var x:Number = 1; x < navNames.length; x++) {
this._parent[navNames[x]].gotoAndStop(1);
this._parent[navNames[x]].enabled = true;
}
this.gotoAndStop(3);
this.enabled = false;
[color=blue]/*this is where I am having problems..... I want the button that is clicked to call the function [loadMenus()] - So I need for an expression (i think...) that goes here - loadmenus (What goes in here?); [/color]
[color=blue]If I use the trace object to trace(this); and click the first button, I am presented with the results "_level0.1 " and the second button "_level0.02" ... So I think I am nearly there...... What do I need to do ??? */[/color]
trace(this);
loadMenus(); [color=blue]//what goes in here[/color]
[color=blue]/* if I were to put a number between the parentheses 1 or 2 or 3 etc "loadMenus(1); it loads the corresponding movie perfectly*/[/color]
}
[color=blue]//This is the function that I wish to call.....[/color]
function loadMenus(newMenu:Number) {
currentMenu = newMenu;
if (_root.currMovie == undefined) {
path = "movies/"
_root.currMovie = _root.navNames[currentMenu];
container.loadMovie(path + "nav" + navNames[currentMenu] +".swf");
} else if (_root.currMovie != navNames[currentMenu]) {
if (container._currentframe >= container.midframe) {
_root.currMovie = navNames[currentMenu];
container.play();
}
}
}
/*I appreciate any help or suggestions that you may have… Cheers
Frustrated and Depressed but still Battling */