944,103 Members | Top Members by Rank

Ad:
Feb 28th, 2007
0

Question regarding multidimensional array for navigation bar

Expand Post »
I'm using a multidimensional array to create a basic nav bar for a website i've been working on for a while.. I'm still very much a "noob" to programming, which is most likely the reason for the concussion I've sustained from repeatedly slamming my head against my desk.

anyway my problem is that i can't figure out how to "target" the specific buttons in my sub-menu (the drop down).. I've figured out how to target the buttons as a whole (as in when i use a trace command, they all perform identically, ((the sub menu vs, the primary))) ...

I'm also having a wee bit of trouble with rollover effects, but at the moment they are the least of my concern... I need to know what i need to do to, say, make it so the "accessories" button either initiates a loadMovieNum() or getURL command.... I appreciate any help anyone can offer, and I also appreciate all the help which has been provided in the past...

I've pasted the code below,



#include "lmc_tween.as"
// ### Array and Variables ### \\
var menu_arr:Array = new Array([["Home"], "home"], [["Motorcycles", "Parts", "Accessories", "Gear", "Store"], "inst"], [["Quads", "Parts", "Accessories", "Gear", "Store"], "Go To Store"], [["Department", "Water Sports", "Toy Haulers", "Fu"],"page"], [["Contact", "Location", "Email"],"contact"]);
//var menu_arr:Array = new Array([["Home"], "home"], [["Instructions", "how", "what", "where", "**** it"], "inst"], [["Play Game", "who", "why"], "playGame"], [["Create Character"], "create"], [["Quit Game"], "quit"]);\\
// ### Functions ### \\
function makeMenu() {
for (var i:Number = 0; i < menu_arr.length; i++) {
var newName:MovieClip = this.attachMovie("item_mc", menu_arr[i][1] + "_mc", this.getNextHighestDepth());
newName._alpha = 0;
var newX:Number = Math.abs((newName._width + 15) * i);
newName._x = Stage.width + 200;
newName._y = 50;
newName.id = i; // Refers to current array index.
newName.slideTo(newX, "_y", 2, "linear", i / 8);
newName.alphaTo(100, 2, "linear", i / 8);
newName.item_txt.text = menu_arr[i][0][0];
newName.onRollOver = function() {
makeSubMenu(this.id, this._x);
}
newName.onRelease = function() {
trace(this.id);
}

}
}

function makeSubMenu(mainId, mainX) {
container_mc.removeMovieClip();
this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
for (var i:Number = 1; i < menu_arr[mainId][0].length; i++) {
//trace(i);
var newSub:MovieClip = container_mc.attachMovie("item_mc", "sub" + i + "_mc", i);
newSub._x = mainX;// Math.abs(mainX + ((newSub._width + 2) * (i - 1)));
newSub._y = Math.abs(100 + ((newSub._height + 2) * (i - 1)));
newSub.item_txt.text = menu_arr[mainId][0][i];
newSub._alpha = 0;
newSub.alphaTo(100, 1, "linear");
newSub.onRollOver = function(){
this.gotoAndPlay(2);
}
newSub.onRollOut = function(){
gotoAndPlay(1);
}

newSub.onRelease = function(){
trace("this button werks d**che bag...");
}
}
}
//newName.onRollOut = function(){
// this.newSub.alphaTo(0, 1, "linear", 0);
//}
makeMenu();
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Matty J is offline Offline
6 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Graphics and Multimedia Forum Timeline: MySpace is your worst parental nightmare
Next Thread in Graphics and Multimedia Forum Timeline: streaming media - avi or mov ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC