Hi,
I’m somewhat new to actionscripting, and I’m having several problems creating a dynamic XML driven menu. There are two problems. The informations being grabbed from the arrays are not working properly. Second, the drop-down is not functioning correctly.
For some reason I am not able to upload files greater than 74 kb, so I am going to attempt to explain the code below.
Menu Array
The array “headers” is the actual text that will be displayed, the array “varnames” are the names of each of the arrays below it so I can call those arrays.
var headers = ["PORTFOLIO", "ABOUT 5DPI", "FORUMS", "JOBS", "CONTACT US"];
var varnames = ["portfolio", "about", "forums", "jobs", "contact"];
var portfolio = ["WEB", "PRINT", "PHOTOGRAPHY", "MISC"];
var about = ["WHAT WE DO", "LOCATION"];
var forums = ["TUTORIALS", "ART GALLERIES", "GENERAL"];
var jobs = ["APPLY"];
var contact = ["QUOTES", "INQUIRY"];
var array_count = [4, 2, 3, 1, 2];
Below, I have 3 important movieclips being used to create the menu. These are “title_mc”, “button_info”, and “hover_button”.
for(var k:Number = 0; k < 5; k++)
{
//creates several "title_mc" movieclips
attachMovie("title_mc", "title_mc" + k, k + 100);
//var select:MovieClip = eval("title_mc" + k);
attachMovie("arrow", "arrow" + k, k-6);
_root["arrow" + k]._x = 15 + 98*k;
_root["arrow" + k]._y = 51;
//incremental x-distance for titles
_root["title_mc" + k]._x = 50 + 98*k;
_root["title_mc" + k]._y = 50;
_root["title_mc" + k].title.text = headers[k];
_root["title_mc" + k].shadow.text = headers[k];
//target distances of "hover_button" movieclips
var targety:Number = getProperty("title_mc" + k, _y) + 13;
var targety_text:Number = getProperty("title_mc" + k, _y) + 7;
var n:Number = array_count[k];
for(var i:Number = 0; i < n; i++)
{
//creates text information on drop-down buttons
attachMovie("button_info", "button_info" + i, i + 50);
//gets position of "title_mc" movieclips generated above
_root["button_info" + i]._x = getProperty("title_mc" + k, _x) - 27;
_root["button_info" + i]._y = getProperty("title_mc" + k, _y) - 6;
_root["button_info" + i]._alpha = 0;
//calling respective arrays below
if(varnames[k] == "portfolio") {
_root["button_info" + i].links.text = portfolio*;
}
else if (varnames[k] == "about") {
_root["button_info" + i].links.text = about*;
}
else if (varnames[k] == "forums") {
_root["button_info" + i].links.text = forums*;
}
else if (varnames[k] == "jobs") {
_root["button_info" + i].links.text = jobs*;
}
else if (varnames[k] == "contact") {
_root["button_info" + i].links.text = contact*;
}
//creates button background for drop-down buttons
attachMovie("hover_btn", "hover_btn" + i, i);
_root["hover_btn" + i]._x = getProperty("title_mc" + k, _x) + 8;
_root["hover_btn" + i]._y = getProperty("title_mc" + k, _y);
_root["hover_btn" + i]._alpha = 0;
}
_root["title_mc" + k].onPress = function()
{
onEnterFrame = function()
{
for(var j:Number = 0; j < n; j++)
{
//absolute value of distance between mouse and button
var dx2:Number = Math.abs(_root["hover_btn" + j]._x - _xmouse);
var dy2:Number = Math.abs(_root["hover_btn" + j]._y - _ymouse);
//check to see if mouse is over button and if button is at final position
if (dx2 <= 36 && dy2 <= 5 && Math.abs(targety + j*11 - _root["hover_btn" + j]._y) < 1)
{
_root["hover_btn" + j]._alpha = 100;
}
else
{
_root["hover_btn" + j]._alpha = 0;
}
_root["button_info" + j]._alpha += 10;
//easing motion of menu below
var dy:Number = targety + j*11 - _root["hover_btn" + j]._y;
var dy_text:Number = targety_text + j*11 - _root["button_info" + j]._y;
vy = dy * easing;
vy_text = dy_text * easing;
if(Math.abs(targety + j*11 - _root["hover_btn" + j]._y) < 1)
{
_root["hover_btn" + j]._y = targety + j*11;
_root["button_info" + j]._y = targety_text + j*11;
}
else
{
_root["hover_btn" + j]._y = _root["hover_btn" + j]._y + vy;
_root["button_info" + j]._y = _root["button_info" + j]._y + vy_text;
}
}
};
};
}
if anyone decides to look into this and wants the FLA file, they can IM me at ne148on/ MSN me at xrazentertainment@hotmail.com
Thanks a bunch,
Brian.