[FONT=Calibri][SIZE=3]I have taken over the project from another developer and tried to reutilize as much of what was done, specially the menu part which has more AS and I am not an expert in actionscript.[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]It is 98% finished but I am having 2 problems that I cannot fix and was wondering if anyone can have a look and maybe give me some help in sorting it out.[/SIZE][/FONT]
[FONT=Calibri][FONT=Calibri][SIZE=3]1.[/SIZE][/FONT] [/FONT][FONT=Calibri][SIZE=3]When you navigate to Projects/Portfolio -> Resort -> Amangani Villas -> Aman3 (or any other) and then go back to Projects / Portfolio -> Residential -> Warshaw (or any other) the Resort crumb is still showing…[/SIZE][/FONT]
[FONT=Calibri][FONT=Calibri][SIZE=3]2.[/SIZE][/FONT] [/FONT][FONT=Calibri][SIZE=3]When the menu is expanded and the user click anywhere else on the screen the menu should go back to where it was, I have done a little fix on this that now retracts the menu to its initial state but wanted it to show the cookie crumbs rather than initialize the menu ( I can discuss this more with you)[/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#0000ff]http://www.redcubedesign.com/WardBlake/[/COLOR][/SIZE][/FONT]
Here is the AS code that manages all the Menu Nav actions:
// generates a list of menu items (effectively one menu)
// given the inputted parameters. This makes the main menu
// as well as any of the submenus
var activeColor = 0xC8C6B7;
var inactiveColor = 0xCCCCCC;
var activeTxtColor = 0x990000;
var inActiveTxtColor = 0x000000;
var breadCrumbs = [];
breadCrumbs[0] = "Home";
var itemTextFormat = new TextFormat();
itemTextFormat.letterSpacing = .5;
GenerateMenu = function (container, name, x, y, depth, node_xml) {
//trace("name is "+name);
// variable declarations
var curr_node;
var curr_item;
if (curr_menu) {
curr_menu.removeMovieClip();
}
var curr_menu = container.createEmptyMovieClip(name, depth);
curr_menu._alpha = 0;
curr_menu.alphaTo(100,.5);
curr_menu._x = curr_menu._width/2;
// RBF Changed Here Below from .75
curr_menu.slideTo(x,"",.10);
// for all items or XML nodes (items and menus)
// within this node_xml passed for this menu
for (var i = 0; i<node_xml.childNodes.length; i++) {
// movieclip for each menu item
curr_item = curr_menu.attachMovie("menuitem", "item"+i+"_mc", i);
//curr_item._x = 0;
curr_item._y = y+i*curr_item._height;
curr_item.trackAsMenu = true;
//track within item for roll over/out actions
curr_item.isActive = false;
// item properties assigned from XML
curr_node = node_xml.childNodes*;
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
curr_item.name.setTextFormat(itemTextFormat);
// item submenu behavior for rollover event
if (node_xml.childNodes*.nodeName == "menu") {
// open a submenu
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.onDragOver=function () {
if (!this.isActive) {
var x = this._x+this._width;
//var y = this._y;
clearSubMenu(curr_menu);
GenerateMenu(curr_menu,"submenu_mc",x,y,getNextHighestDepth()-2,this.node_xml);
// show a hover color
colorNav(this,node_xml,curr_menu);
this.isActive = true;
}
};
} else {
// nodeName == "item"
curr_item.arrow._visible = false;
// close existing submenu
curr_item.onRollOver = curr_item.onDragOver=function () {
if (!this.isActive) {
clearSubMenu(curr_menu);
//this clears a previous sub menu. remove if they should linger.
GenerateMenu(curr_menu,"submenu_mc",x,y,getNextHighestDepth()-2,this.node_xml);
// show a hover color
colorNav(this,node_xml,curr_menu);
}
};
// only items w/o menu have actions
curr_item.onRelease = function() {
//trace("menu item clicked");
Actions[this.action](this.variables);
if (this.name.text != "Home") {
generateBreadCrumbs();
}
//trace("clear the menu");
CloseSubmenus();
};
}
/*
curr_item.onRollOut = curr_item.onDragOut=function () {
};
// any item, menu opening or not can have actions
curr_item.onRelease = function() {
Actions[this.action](this.variables);
generateBreadCrumbs();
CloseSubmenus();
};*/
}
// end for loop
};
function generateBreadCrumbs() {
//this.alphaTo(0,1);
//this._alpha = 0;
this._visible = 0;
/*this.onRollOver = function() {
//nothing, just disable the buttons within
};*/
 
 
this.useHandCursor = false;
var bMenu;
var bread_menu = _parent.createEmptyMovieClip("crumbs", 1);
for (i=0; i<breadCrumbs.length; i++) {
bMenu = bread_menu.attachMovie("menuitem", "item"+i+"_mc", i);
bMenu._x = _x+i*bMenu._width;
bMenu.name.text = breadCrumbs*;
bMenu.arrow._visible = false;
bMenu._alpha = 0;
bMenu.alphaTo(100,.5,"",i*.1);
bMenu.background.colorTo(activeColor,.5,"",i*.1);
bMenu.name.colorTo(activeTxtColor,.5,"",i*.1);
bMenu.onRelease = function() {
if (this._name == "item0_mc") {
//goHome
doClick("0_1");
}
bread_menu.fadeOut(0,1);
_level0.nav.nav_main.alphaTo(100,1);
delete _level0.nav.nav_main.onRollOver;
_level0.nav.nav_main._visible = true;
};
}
/*bread_menu.onRelease = function() {
bread_menu.fadeOut(0,1);
_level0.nav.nav_main.alphaTo(100,1);
delete _level0.nav.nav_main.onRollOver;
};*/
}
function colorNav(who, node_xml, curr_menu) {
for (var i = 0; i<node_xml.childNodes.length; i++) {
//curr_node = node_xml.childNodes*;
mc = who._parent["item"+i+"_mc"];
if (mc == who) {
//highlight it
//trace(mc);
//trace("who is "+who);
mc.background.colorTo(activeColor,.5);
mc.background.alphaTo(100,.5);
mc.name.colorTo(activeTxtColor,.5);
setCrumb(who,curr_menu);
} else {
//unHighlight it
mc.isActive = false;
mc.background.colorTo(inactiveColor,.5);
mc.background.alphaTo(100,.5);
mc.name.colorTo(inActiveTxtColor,.5);
}
}
}
//
//XXX check here again to clear menu.sub-menu.su-sub-menu
function clearSubMenu(curr_menu) {
trace("this is the submenu:");
trace(curr_menu.submenu_mc);
if (curr_menu.submenu_mc) {
//if there is one remove it, and if history allows pop the breadCrumbs[]
trace("clearing the submenu");
curr_menu.submenu_mc.removeMovieClip();
if (rollHistory(curr_menu, who)) {
breadCrumbs.pop();
//trace("breadCrumbs popped from removing");
}
}
if (curr_menu.submenu_mc == '_level0.nav.nav_main.mainmenu_mc.submenu_mc.submenu_mc.submenu_mc')
{
trace("not doing this");
}
}
function setCrumb(who, curr_menu, node_xml) {
if (who != "clear") {
if (who._parent == mainmenu_mc) {
breadCrumbs = [];
breadCrumbs[0] = "Home";
breadCrumbs.push(who.name.text);
trace("main menu item, clear breadcrumbs and set this crumb "+breadCrumbs);
return;
}
if (!rollHistory(curr_menu, who)) {
breadCrumbs.pop();
breadCrumbs.push(mc.name.text);
trace("breadCrumbs is popped "+breadCrumbs);
return;
}
if (rollHistory(curr_menu, who)) {
breadCrumbs.pop();
trace("breadCrumbs popped");
}
breadCrumbs.push(who.name.text);
trace("breadCrumbs is "+breadCrumbs);
} else {
breadCrumbs = [];
breadCrumbs[0] = "Home";
//breadCrumbs[0] = "Home";
trace("breadCrumbs is cleared "+breadCrumbs);
}
}
var lastMenu:MovieClip;
function rollHistory(curr_menu, who) {
lastMenu = thisMenu;
thisMenu = curr_menu;
//trace("lastMenu "+lastMenu);
//trace("curr_menu "+curr_menu);
if (lastMenu == curr_menu) {
go = false;
//trace("rolling on same menu");
return go;
} else {
go = true;
//trace("NOT rolling on same menu");
return go;
}
//thisRoll = who.name.text;
}
// create the main menu, this will be constantly visible
CreateMainMenu = function (x, y, depth, menu_xml) {
// generate a menu list
GenerateMenu(this,"mainmenu_mc",x,y,depth,menu_xml.firstChild);
// close only submenus if visible durring a mouseup
// this main menu (mainmenu_mc) will remain
/*mainmenu_mc.onMouseUp = function() {
if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
CloseSubmenus();
}
};*/
};
// closes all submenus by removing the submenu_mc
// in the main menu (if it exists)
CloseSubmenus = function () {
mainmenu_mc.submenu_mc.removeMovieClip();
//trace("close subs");
//clear the path
//setCrumb("clear");
};
// This actions object handles methods for actions
// defined by the XML called when a menu item is pressed
Actions = Object();
Actions.clicked = function(clicked) {
trace("doing this A");
mainmenu_mc.submenu_mc.removeMovieClip();
doClick(clicked);
};
Actions.gotoURL = function(urlVar) {
getURL(urlVar, "_blank");
};
/*
Actions.message = function(msg) {
message_txt.text = msg;
};
Actions.newMenu = function(menuxml) {
menu_xml.load(menuxml);
};*/
//init default section
doClick("0_1");
function doClick(clicked) {
if(clicked == "0,1"){
goHome();
}
previousItem = newItem;
newItem = clicked;
if (previousItem != newItem) {
_level0.cont.getContent(clicked);
} else {
trace("same click, do nothing");
}
}
 
//for linking directally to projects
function getInsetSection(who) {
trace("getInsetSection click");
//cont.insetProject = true;
doClick(who);
_parent._visible = false;
_level0.back._visible = true;
}
//for linking directally to Newsroom
function getInsetSectionB(who) {
trace("getInsetSectionB click");
//cont.insetProject = true;
doClick(who);
_parent._visible = true;
_level0.back._visible = false;
}
/*
Screenshot, filters and jpg output
Post your questions on www.flash-db.com/Boards/
import flash.display.BitmapData;
import flash.geom.Matrix;
 
/*
create a function that takes a snapshot of the Video object whenever it is called
and shows in different clips
function makeSnapshot(){
//trace("snapshot");
snapshot = new BitmapData(this._width,this._height);
//draw the current state of the Video object into
//the bitmap object with no transformations applied
snapshot.draw(this,new Matrix());
var t:MovieClip = createEmptyMovieClip("bitmap_mc",5);
t._x = 350; t._y = 20; t._xscale = t._yscale = 50
//display the specified bitmap object inside the movie clip
t.attachBitmap(snapshot,1);
//trace(t);
}
*/
// load XML, when done, run CreateMainMenu to interpret it
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
// create main menu after successful loading of XML
if (ok) {
CreateMainMenu(0,0,0,this);
//message_txt.text = "message area";
} else {
//message_txt.text = "error: XML not successfully loaded";
}
};
// load first XML menu
menu_xml.load("menu1.xml");
I can send you menu xml file, if you think you can help.
Many thanks
Best
R