frankybones
asked on
Vertical Cascading Menu driven by XML
I know how to build a menu in flash using XML, but I want to know how to assign ActionScript to make it cascade on rollover. So if I have a structured the following in XML
main btn
sub btn
sub btn
sub btn
sub btn
main btn
sub btn
sub btn
main btn
sub btn
main btn
main btn
that when you roll over the main btns the sub buttons cascade down and the other main buttons underneath move down as well. Am I being clear because I do not feel like I am? Also thank you in advanace for your help.
Franky
main btn
sub btn
sub btn
sub btn
sub btn
main btn
sub btn
sub btn
main btn
sub btn
main btn
main btn
that when you roll over the main btns the sub buttons cascade down and the other main buttons underneath move down as well. Am I being clear because I do not feel like I am? Also thank you in advanace for your help.
Franky
ASKER
I understand how to make an object that is already on the stage move using easing. Yet again I am loading all of my buttons into a blank mc from the library. How many buttons depends on how many are defined in an XML file. I do not know how to assign the easing to a button that does not exist on a stage or how to tell it to ease the buttons below it because they are attached via this script:
menu.attachMovie("button", "btn"+i, 5000+i);
Also when you rollover the button I want the sub buttons to be attached and the rest of the menu to move down as to reveal the sub menu. Here is an example of what I am sort of doing:
http://www.kirupa.com/developer/actionscript/xml_dropdown_menu4.htm
Except instead of the sub menus showing up to the side I want the other buttons to slide down and the sub buttons show up in between. Like this but without using CSS:
http://www.frunder.com/products/flash/menu/demos.htm
And I do not want to buy this, I want to understand how to do it.
Thank you for your efforts,
Franky
menu.attachMovie("button",
Also when you rollover the button I want the sub buttons to be attached and the rest of the menu to move down as to reveal the sub menu. Here is an example of what I am sort of doing:
http://www.kirupa.com/developer/actionscript/xml_dropdown_menu4.htm
Except instead of the sub menus showing up to the side I want the other buttons to slide down and the sub buttons show up in between. Like this but without using CSS:
http://www.frunder.com/products/flash/menu/demos.htm
And I do not want to buy this, I want to understand how to do it.
Thank you for your efforts,
Franky
ASKER
Okay, here is my code that I have so far. The only thing that I am lacking is the ability to make it move on a mouse event. If you need to see the fla. let me know and I will post on a website in a zip file for download. Now for the code that I have:
Stage.showMenu = false;
Stage.align = "TL";
Stage.scaleMode = "noScale";
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
// create menu after successful loading of XML
if (ok) {
create_menu();
} else {
trace("XML not loaded");
}
};
// load XML menu
menu_xml.load("XML/forkMen u2.xml");
//
total_subs = 0;
most_subs = 0;
function create_menu() {
//Load menu options from XML
rollover_delay = menu_xml.firstChild.childN odes[0].at tributes.r ollover_de lay;
text_color1 = "0x"+menu_xml.firstChild.c hildNodes[ 0].attribu tes.text_c olor1;
text_color2 = "0x"+menu_xml.firstChild.c hildNodes[ 0].attribu tes.text_c olor2;
//internally set options
var menuSpacer = .5;
//sets the vertical space between main items
var subSpacer = 0;
//sets the vertical space between sub items
var menuSpeed = 3;
//sets the menu animation speed
var menuTolerance = 1;
var subDelay = 50;
//set the delay for the sub items entering the stage
var itemDelay = 100;
//creat main menu
for (i=1; i<menu_xml.firstChild.chil dNodes.len gth; i++) {
my_menu2.attachMovie("butt on_typeSub ", "sub2"+i, i);
my_menu2.attachMovie("butt on_type2", "btn2"+i, 5000+i);
//set button position
my_menu2["btn2"+i]._x = 4;
my_menu2["btn2"+i]._y = (my_menu["btn2"+i]._height +menuSpace r)*i;
//set button text attributes
my_menu2["btn2"+i].textul. textColor = text_color1;
my_menu2["btn2"+i].the_tex t = menu_xml.firstChild.childN odes[i].at tributes.t ext;
//set button color
main_btn_color = new Color(my_menu2["btn2"+i].c olor_clip) ;
main_btn_color.setRGB("0x" +menu_xml. firstChild .childNode s[0].attri butes.main _buttons_c olor);
//set actions
my_menu["sub2"+i].menu_num ber = i;
my_menu2["btn2"+i].menu_nu mber = i;
my_menu2["btn2"+i].what = menu_xml.firstChild.childN odes[i].at tributes.w hat;
my_menu2["btn2"+i].where = menu_xml.firstChild.childN odes[i].at tributes.w here;
my_menu2["btn2"+i].the_typ e = menu_xml.firstChild.childN odes[i].at tributes.t ype;
my_menu2["btn2"+i].onRelea se = function() {
if (this.the_type != undefined) {
if ((this.the_type == "geturl") or (this.the_type == "getURL")) {
unloadMovie(_root.dropZone );
getURL(this.what, this.where);
}
if ((this.the_type == "gotoAndPlay") or (this.the_type == "gotoandplay")) {
unloadMovie(_root.dropZone );
tellTarget (this.where) {
gotoAndPlay(this.what);
}
}
if ((this.the_type == "gotoAndStop") or (this.the_type == "gotoandstop")) {
unloadMovie(_root.dropZone );
tellTarget (this.where) {
gotoAndStop(this.what);
}
}
if ((this.the_type == "loadMovie") or (this.the_type == "loadmovie")) {
loadMovie(this.what, this.where);
}
if ((this.the_type == "attachMovie") or (this.the_type == "attachmovie")) {
tellTarget (this.where) {
attachMovie(this.what, this.what+i, i);
}
}
if ((this.the_type == "fsCommand") or (this.the_type == "fscommand")) {
unloadMovie(_root.dropZone );
fscommand(this.what, this.where);
}
if ((this.the_type == "function") or (this.the_type == "Function")) {
unloadMovie(_root.dropZone );
eval(this.where)[this.what ]();
}
}
};
//if the node has childs create sub buttons
if (menu_xml.firstChild.child Nodes[i].h asChildNod es()) {
create_sub(i);
}
}
}
function create_sub(the_node) {
for (ii=0; ii<menu_xml.firstChild.chi ldNodes[th e_node].ch ildNodes.l ength; ii++) {
my_menu["sub2"+the_node].a ttachMovie ("button_t ypeSub", "s"+ii, 8000+ii);
//set button text attributes
my_menu2["sub2"+the_node][ "s"+ii].te xtul.textC olor = text_color1;
my_menu2["sub2"+the_node][ "s"+ii].th e_text = menu_xml.firstChild.childN odes[the_n ode].child Nodes[ii]. attributes .text;
//set button color
sub_btn_color = new Color(my_menu2["sub2"+the_ node]["s"+ ii].color_ clip);
sub_btn_color.setRGB("0x"+ menu_xml.f irstChild. childNodes [the_node] .childNode s[ii].attr ibutes.mai n_buttons_ color);
//set actions
my_menu2["sub2"+the_node][ "s"+ii].wh at = menu_xml.firstChild.childN odes[the_n ode].child Nodes[ii]. attributes .what;
my_menu2["sub2"+the_node][ "s"+ii].wh ere = menu_xml.firstChild.childN odes[the_n ode].child Nodes[ii]. attributes .where;
my_menu2["sub2"+the_node][ "s"+ii].th e_type = menu_xml.firstChild.childN odes[the_n ode].child Nodes[ii]. attributes .type;
//
my_menu["sub"+the_node]["s "+ii].onRe lease = function() {
if (this.the_type != undefined) {
if ((this.the_type == "geturl") or (this.the_type == "getURL")) {
unloadMovie(_root.dropZone );
getURL(this.what, this.where);
}
if ((this.the_type == "gotoAndPlay") or (this.the_type == "gotoandplay")) {
tellTarget (this.where) {
gotoAndPlay(this.what);
}
}
if ((this.the_type == "gotoAndStop") or (this.the_type == "gotoandstop")) {
unloadMovie(_root.dropZone );
tellTarget (this.where) {
gotoAndStop(this.what);
}
}
if ((this.the_type == "loadMovie") or (this.the_type == "loadmovie")) {
loadMovie(this.what, this.where);
}
if ((this.the_type == "attachMovie") or (this.the_type == "attachmovie")) {
attachMovie(this.what, this.where);
}
if ((this.the_type == "fsCommand") or (this.the_type == "fscommand")) {
unloadMovie(_root.dropZone );
fscommand(this.what, this.where);
}
if ((this.the_type == "function") or (this.the_type == "Function")) {
unloadMovie(_root.dropZone );
eval(this.where)[this.what ]();
}
}
};
}
}
Stage.showMenu = false;
Stage.align = "TL";
Stage.scaleMode = "noScale";
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
// create menu after successful loading of XML
if (ok) {
create_menu();
} else {
trace("XML not loaded");
}
};
// load XML menu
menu_xml.load("XML/forkMen
//
total_subs = 0;
most_subs = 0;
function create_menu() {
//Load menu options from XML
rollover_delay = menu_xml.firstChild.childN
text_color1 = "0x"+menu_xml.firstChild.c
text_color2 = "0x"+menu_xml.firstChild.c
//internally set options
var menuSpacer = .5;
//sets the vertical space between main items
var subSpacer = 0;
//sets the vertical space between sub items
var menuSpeed = 3;
//sets the menu animation speed
var menuTolerance = 1;
var subDelay = 50;
//set the delay for the sub items entering the stage
var itemDelay = 100;
//creat main menu
for (i=1; i<menu_xml.firstChild.chil
my_menu2.attachMovie("butt
my_menu2.attachMovie("butt
//set button position
my_menu2["btn2"+i]._x = 4;
my_menu2["btn2"+i]._y = (my_menu["btn2"+i]._height
//set button text attributes
my_menu2["btn2"+i].textul.
my_menu2["btn2"+i].the_tex
//set button color
main_btn_color = new Color(my_menu2["btn2"+i].c
main_btn_color.setRGB("0x"
//set actions
my_menu["sub2"+i].menu_num
my_menu2["btn2"+i].menu_nu
my_menu2["btn2"+i].what = menu_xml.firstChild.childN
my_menu2["btn2"+i].where = menu_xml.firstChild.childN
my_menu2["btn2"+i].the_typ
my_menu2["btn2"+i].onRelea
if (this.the_type != undefined) {
if ((this.the_type == "geturl") or (this.the_type == "getURL")) {
unloadMovie(_root.dropZone
getURL(this.what, this.where);
}
if ((this.the_type == "gotoAndPlay") or (this.the_type == "gotoandplay")) {
unloadMovie(_root.dropZone
tellTarget (this.where) {
gotoAndPlay(this.what);
}
}
if ((this.the_type == "gotoAndStop") or (this.the_type == "gotoandstop")) {
unloadMovie(_root.dropZone
tellTarget (this.where) {
gotoAndStop(this.what);
}
}
if ((this.the_type == "loadMovie") or (this.the_type == "loadmovie")) {
loadMovie(this.what, this.where);
}
if ((this.the_type == "attachMovie") or (this.the_type == "attachmovie")) {
tellTarget (this.where) {
attachMovie(this.what, this.what+i, i);
}
}
if ((this.the_type == "fsCommand") or (this.the_type == "fscommand")) {
unloadMovie(_root.dropZone
fscommand(this.what, this.where);
}
if ((this.the_type == "function") or (this.the_type == "Function")) {
unloadMovie(_root.dropZone
eval(this.where)[this.what
}
}
};
//if the node has childs create sub buttons
if (menu_xml.firstChild.child
create_sub(i);
}
}
}
function create_sub(the_node) {
for (ii=0; ii<menu_xml.firstChild.chi
my_menu["sub2"+the_node].a
//set button text attributes
my_menu2["sub2"+the_node][
my_menu2["sub2"+the_node][
//set button color
sub_btn_color = new Color(my_menu2["sub2"+the_
sub_btn_color.setRGB("0x"+
//set actions
my_menu2["sub2"+the_node][
my_menu2["sub2"+the_node][
my_menu2["sub2"+the_node][
//
my_menu["sub"+the_node]["s
if (this.the_type != undefined) {
if ((this.the_type == "geturl") or (this.the_type == "getURL")) {
unloadMovie(_root.dropZone
getURL(this.what, this.where);
}
if ((this.the_type == "gotoAndPlay") or (this.the_type == "gotoandplay")) {
tellTarget (this.where) {
gotoAndPlay(this.what);
}
}
if ((this.the_type == "gotoAndStop") or (this.the_type == "gotoandstop")) {
unloadMovie(_root.dropZone
tellTarget (this.where) {
gotoAndStop(this.what);
}
}
if ((this.the_type == "loadMovie") or (this.the_type == "loadmovie")) {
loadMovie(this.what, this.where);
}
if ((this.the_type == "attachMovie") or (this.the_type == "attachmovie")) {
attachMovie(this.what, this.where);
}
if ((this.the_type == "fsCommand") or (this.the_type == "fscommand")) {
unloadMovie(_root.dropZone
fscommand(this.what, this.where);
}
if ((this.the_type == "function") or (this.the_type == "Function")) {
unloadMovie(_root.dropZone
eval(this.where)[this.what
}
}
};
}
}
ASKER
Anyone?
ASKER
I got it figured out and I am asking that since none of the response helped that this be closed and that my points be refunded.
FB
FB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://www.experts-exchange.com/questions/21763588/slider-menu-question.html#16124048
BR Dushan