hey all, can’t get this to work, i can make the menu collapse but I can’t make the arrow rotate.
FYI… I have a button on top of my menu that says “collapse”. it does collapse the menu but like I said, I am having trouble controlling the arrow
sry for the long code but…
/********* CREDITS **********\
* Author: lostinbeta
* Date: 01/29/2003
*
* Amends: senocular
* 01/30/2003
\****************************/
// variables:
menuSpeed = 17;
arrowSpeed = 35;
vSpacing = 14;
scope = this;
scope.createEmptyMovieClip("mainMenu",2);
/*** mainMenu controls menu movement in onEnterFrame ***/
mainMenu.onEnterFrame = function(){
if (this.onClosedMenu || this.pos != this.offset){
if (Math.abs(this.pos - this.offset) <= menuSpeed){
this.pos = this.offset;
this.SlideButtons();
if (this.onClosedMenu){
this.onClosedMenu();
delete this.onClosedMenu;
}
}else{
this.pos = (this.pos > this.offset) ? this.pos - menuSpeed : this.pos + menuSpeed;
this.SlideButtons();
}
}
}
/*** used in mainMenu onEnterFrame ***/
mainMenu.SlideButtons = function(){
// starts at the dropstart clip (ID) as set by mainMenu.onClosedMenu
var i;
for (i=this.dropStart+1; i<menuItem.length+1; i++){
var currButton = this["button"+i];
currButton._y = currButton.homePosition + this.pos;
}
}
/*** used in menu button onReleases for arrow rotation ***/
MovieClip.prototype.setToRotateTo = function(rotation){
this.rotateTo = rotation;
this.onEnterFrame = function(){
this._rotation = (this._rotation > this.rotateTo) ? this._rotation - arrowSpeed : this._rotation + arrowSpeed
if (Math.abs(this.rotateTo - this._rotation) <= arrowSpeed){
this._rotation = this.rotateTo;
delete this.onEnterFrame;
}
}
}
GenerateMenu = function(success) {
if (success) {
menuItem = this.firstChild.childNodes;
for (i=0; i<menuItem.length; i++) {
/*** make a button for each itme layed out in the XML ***/
myButton = mainMenu.attachMovie("button", "button"+i, i);
myButton.ID = i;
myButton.buttonLabel.text = menuItem*.attributes.NAME;
myButton.subMenus = menuItem*.childNodes.length;
/*** if has sub menus ***/
if (myButton.subMenus){
myButton.subMenuItem = menuItem*.childNodes;
/*** used in mainMenu.onClosedMenu to generate the new submenu ***/
myButton.createSubMenu = function(){
mySubMenu = scope.createEmptyMovieClip("subMenu",1); // lower than main menu
mySubMenuMask = scope.createEmptyMovieClip("menuMask",3);
for (j=0; j<this.subMenus; j++){ // create each submenu button
mySubButton = scope.subMenu.attachMovie("button", "button"+j, j);
new Color(mySubButton).setTransform({rb:33, gb:33, bb:33});
mySubButton.buttonLabel.text = this.subMenuItem[j].attributes.NAME;
mySubButton.myUrl = this.subMenuItem[j].attributes.URL;
mySubButton.myTarget = this.subMenuItem[j].attributes.TARGET;
mySubButton.onRelease = function() {
getURL(this.myUrl, this.myTarget);
trace(this.buttonLabel.text+" : "+this.myURL);
}
mySubButton.onRollOver = function() { this.glare.play(); }
mySubButton._x = this._x;
mySubButton._y = this._y + vSpacing*(j+1);
mySubButton.arrow.swapDepths(0);
mySubButton.arrow.removeMovieClip();
}
}
/*** drop-down menu release actions ***/
myButton.onRelease = function() {
if (mainMenu.currentSubMenu != this){
mainMenu.currentSubMenu.arrow.setToRotateTo(0);
mainMenu.currentSubMenu = this;
/*** set new menu positioning ***/
var currButton = this;
mainMenu.onClosedMenu = function(){ // runs when menu closes
this.offset = vSpacing * currButton.subMenus;
this.dropStart = currButton.ID;
this.currentSubMenu.createSubMenu();
currButton.arrow.setToRotateTo(90);
}
mainMenu.offset = 0; // set offset to 0 to close, when closed it runs onClosedMenu
/*** if this menu is open, close ***/
}else{
mainMenu.currentSubMenu = null;
this.arrow.setToRotateTo(0);
mainMenu.offset = 0; // set offset to 0 to close
}
}
/*** if no submenus, make a normal link button ***/
}else{
myButton.myUrl = menuItem*.attributes.URL;
myButton.myTarget = menuItem*.attributes.TARGET;
myButton.onRelease = function() {
getURL(this.myUrl, this.myTarget);
trace(this.buttonLabel.text+" : "+this.myURL);
}
myButton.arrow.swapDepths(0);
myButton.arrow.removeMovieClip();
}
/*** all menu buttons ***/
myButton.onRollOver = function() { this.glare.play(); }
myButton._x = -1
myButton._y = -2; // position
myButton.homePosition = myButton._y += vSpacing*i;
}
/*** attach dummy button below menu to cover underlying submenus ***/
myButton = mainMenu.attachMovie("dumbutton", "button"+i, i);
myButton._x = myButton._y = 16;
myButton.homePosition = myButton._y += vSpacing*i;
/*** if no success ***/
} else {
trace("XML File Loading Failed");
}
};
/*** retrieve XML data then generate menu ***/
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = GenerateMenu;
myXML.load("navMenu.xml");
now i’m not sure why this won’t work
menu.onRelease = function(){
mainMenu.currentSubMenu = null;
this.arrow.setToRotateTo(10);
mainMenu.offset = 0; // set offset to 0 to close
}
Thanks
:-\ :-\ :-\