Hi, fellas.
I’m working on a menu system for our website - the menu, as is, is similar to the one found on macromedia.com (the main menu and the submenu laid out horizontally across the screen). how do i make it so that the submenu is vertical and located under the appropriate menu heading? Here’s the AS that I used:
_global.navXPos = 20;
var root_mc:MovieClip = this;
//
navButton("home_mc", "Home", "default.htm");
var solutionsSubNav_array:Array = new Array();
solutionsSubNav_array.push({instance:'as_mc', txt:'Answering Solutions', href:'as.htm'});
solutionsSubNav_array.push({instance:'restaurant_mc', txt:'Restaurant Order Taking', href:'restaurant.htm'});
solutionsSubNav_array.push({instance:'government_mc', txt:'Government Entities', href:'government.htm'});
solutionsSubNav_array.push({instance:'corporate_mc', txt:'Corporate', href:'corporate.htm'});
solutionsSubNav_array.push({instance:'business_mc', txt:'Small Business', href:'business.htm'});
solutionsSubNav_array.push({instance:'property_mc', txt:'Property Management', href:'property.htm'});
solutionsSubNav_array.push({instance:'customize_mc', txt:'Customize A Solution', href:'customize.htm'});
navButton("solutions_mc", "Solutions", "solutions.htm", solutionsSubNav_array);
var prSubNav_array:Array = new Array();
prSubNav_array.push({instance:'news_mc', txt:'News', href:'news.htm'});
prSubNav_array.push({instance:'whitepapers_mc', txt:'White Papers', href:'whitepapers.htm'});
prSubNav_array.push({instance:'faq_mc', txt:'FAQ', href:'faq.htm'});
navButton("pr_mc", "Public Relations", "#", prSubNav_array);
var contactSubNav_array:Array = new Array();
contactSubNav_array.push({instance:'contactus_mc', txt:'Contact Us', href:'contact.aspx'});
contactSubNav_array.push({instance:'employment_mc', txt:'Employment Info.', href:'jobs.htm'});
navButton("contact_mc", "Contact", "#", contactSubNav_array);
function navButton(instanceName_str:String, label_str:String, target_str:String, subMenu_array:Array):Void {
var target_mc:MovieClip = root_mc.createEmptyMovieClip(instanceName_str, root_mc.getNextHighestDepth());
var box_mc:MovieClip = target_mc.createEmptyMovieClip("box_mc", target_mc.getNextHighestDepth());
var label_mc:MovieClip = target_mc.attachMovie("navBtn", "label_mc", target_mc.getNextHighestDepth(), {_x:_global.navXPos, _y:0});
label_mc.label_txt.text = label_str;
label_mc.label_txt.autoSize = true;
box_mc._x = label_mc._x;
var txtWidth:Number = label_mc.label_txt._width+27;
var txtHeight:Number = label_mc.label_txt._height+7;
drawRectangle(box_mc, 0xFFFFFF, 50, txtWidth, txtHeight);
box_mc._alpha = 0;
box_mc._y = 1;
_global.navXPos += txtWidth;
box_mc.onRollOver = function() {
var fade_tween:Object = new mx.transitions.Tween(box_mc, "_alpha", mx.transitions.easing.None.easeNone, 0, 100, 7, false);
var sub_mc:MovieClip = root_mc.createEmptyMovieClip("subNav_mc", 000);
sub_mc._y = 36;
_global.subNavXPos = 1;
var numSubMenuItems:Number = subMenu_array.length;
for (var i = 0; i<numSubMenuItems; i++) {
var thisSubMenuItem:Object = subMenu_array*;
var subNavBtn_mc:MovieClip = sub_mc.attachMovie("subNavBtn", thisSubMenuItem.instance, sub_mc.getNextHighestDepth(), {_x:_global.subNavXPos});
subNavBtn_mc.href = thisSubMenuItem.href;
subNavBtn_mc.label_txt.text = thisSubMenuItem.txt;
subNavBtn_mc.label_txt.autoSize = true;
subNavBtn_mc.onRollOver = function() {
var btnWidth:Number = this._width;
var btnHeight:Number = 1;
drawLine(this, 0xC1C1C1, 50, btnWidth, btnHeight+2);
};
subNavBtn_mc.onRollOut = function() {
this.clear();
};
subNavBtn_mc.onRelease = function() {
getURL(this.href);
};
_global.subNavXPos += subNavBtn_mc._width+10;
}
new mx.transitions.Tween(sub_mc, "_alpha", mx.transitions.easing.Regular.easeOut, 0, 100, 1, true);
};
box_mc.onRollOut = function() {
new mx.transitions.Tween(this, "_alpha", mx.transitions.easing.None.easeNone, 100, 0, 7, false);
};
box_mc.onRelease = function() {
getURL(target_str);
};
}
function drawRectangle(target_mc:MovieClip, fillColor:Number, alpha:Number, width:Number, height:Number):Void {
with (target_mc) {
beginFill(fillColor, alpha);
moveTo(0, 0);
lineTo(width, 0);
lineTo(width, height);
lineTo(0, height);
lineTo(0, 0);
endFill();
}
}
function drawLine(target_mc:MovieClip, fillColor:Number, alpha:Number, width:Number, height:Number):Void {
with (target_mc) {
beginFill(fillColor, alpha);
lineStyle(1, 0x000000, 50);
moveTo(-1, 3);
lineTo(0, 2);
lineTo(width, 2);
lineTo(width+1, 3);
lineTo(width+1, height+13);
lineTo(width, height+14);
lineTo(0, height+14);
lineTo(-1, height+13)
lineTo(-1, 3);
endFill();
}
}
thanks very much.