Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-26-2010, 03:09 PM   #1
farther_north
Registered User
 
Join Date: Apr 2010
Posts: 3
Default Navigation/Sub Menu help (xml/AS2/Arrays)

I am working on a multi-level navigation and have run into some issues. The arrays seem to be working, I am able to see the content and trace the variables.

However, when I am trying to set the functions when the buttons are pressed - the variables become undefined. My code is here:

// Setting arrays

var menuButtons:Array = new Array();
menuButtons = siteConfigArray[0][0];
trace("totalSections : " +menuButtons.length);
var subMenu:Array = new Array();

// loads the data into arrays
for(i=0;i<menuButtons.length;i++){

for(j=0;j<menuButtons[i].length;j++){
subMenu[i] = menuButtons[i]
}
}

var chosenMenu:Array = new Array();
var subMenuOpened:Boolean = false;
var whichSubMenu:Number = new Number();
var currentPosition:Number = new Number();

for (i=0; i<menuButtons.length; i++) {
this.attachMovie("menu button", "menuButton"+i, this.getNextHighestDepth());
this["menuButton"+i]._x = 30+(115*i);
this["menuButton"+i]._y = 6;
this["menuButton"+i].label_txt.text = menuButtons[i].title;
var mainMenuColor:Color = new Color(this["menuButton"+i].bkgColor_mc);
mainMenuColor.setRGB(0x006699);
this["menuButton"+i].onRollOver = function():Void {

loadNewSection(chosenMenu[j].module, chosenMenu[j].title, chosenMenu
[j].module_id);

whichSubMenu = Number(this._name.substr(-1, 1));
currentPosition = this._x;
if (!subMenuOpened) {
subMenuOpened = true;
openSubMenu(whichSubMenu, currentPosition);
} else {
closeSubMenu();
openSubMenu(whichSubMenu, currentPosition);
}
};
}

function openSubMenu(whichSubMenu, currentPosition):Void {
chosenMenu = eval("subMenu"+(whichSubMenu+1));
for (j=0; j<chosenMenu.length; j++) {
this.createEmptyMovieClip("subMenuHolder_mc", this.getNextHighestDepth());
subMenuHolder_mc.attachMovie("menu button", "subMenuButton"+j, this.getNextHighestDepth());
subMenuHolder_mc["subMenuButton"+j]._x = currentPosition;
subMenuHolder_mc["subMenuButton"+j]._y = 29+(j*23);
subMenuHolder_mc["subMenuButton"+j].label_txt.text = chosenMenu[j].title;
var subMenuStartColor:Color = new Color(subMenuHolder_mc["subMenuButton"+j].bkgColor_mc);
subMenuStartColor.setRGB(0x81A3E2);
subMenuHolder_mc["subMenuButton"+j].onRelease = subMenuHolder_mc["subMenuButton"+j].onReleaseOutside=function ():Void {
loadNewSection(chosenMenu[j].module, chosenMenu[j].title, chosenMenu[j].module_id);
closeSubMenu();
};
subMenuHolder_mc["subMenuButton"+j].onRollOver = function():Void {
var subMenuRollOverColor:Color = new Color(this.bkgColor_mc);
subMenuRollOverColor.setRGB(0xFF6600);
};
subMenuHolder_mc["subMenuButton"+j].onRollOut = function():Void {
var subMenuRollOutColor:Color = new Color(this.bkgColor_mc);
subMenuRollOutColor.setRGB(0x81A3E2);
};
}
}

I feel like I am really close.
farther_north is offline   Reply With Quote
Old 04-26-2010, 07:53 PM   #2
farther_north
Registered User
 
Join Date: Apr 2010
Posts: 3
Default

I have further isolated the issue.. this is exactly how my acctionscript appears.

these lines trace to values:
trace("Menu module_id above onrollover : " +menuButtons[i].module_id);
trace("Menu module : " +menuButtons[i].module);
trace("Menu link : " +menuButtons[i].direct_link);
trace("Menu title : " +menuButtons[i].title);

this["menuButton"+i].onRollOver = function():Void {
// these trace to undefined
trace("Menu module_id below onrollover : " +menuButtons[i].module_id);
trace("Menu module : " +menuButtons[i].module);
trace("Menu link : " +menuButtons[i].direct_link);
trace("Menu title : " +menuButtons[i].title);
farther_north is offline   Reply With Quote
Old 04-27-2010, 03:04 AM   #3
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

What does the value of i alone trace to in the onRollOver?
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:21 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.