Hi there
I have been working on creating a menu that will be driven by an Articulate presentation.
I have used senocular’s XML-Driven Drop-Down-Menu tutorial (THANKS FOR THE TUT BTW) as the base and adapted it to read in from the artAPI rather than an XML file.
My problem is that although I can build the menu and have sub menu’s appear every element of the menu is included in all levels.
I probably haven’t made myself very clear but have posted the actionscript below. What I need is if the curr_slide is a level 0 it will appear in the top level menu and if its a level 1 it will appear as a sub menu of the level 0 above it.
I did try to attach a zip of the whole example but it was 555kb and exceded the site file limit. So I have uploaded it here http://www.cblendedlearning.com/menu_sample.zip
Hope some one can help me from pulling my hair out.
stop();
var nSlideCount = ArtAPI.GetSlideCount();
//
// 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
GenerateMenu = function(container, name, x, y, depth, slide_ref) {;
// variable declarations
var curr_slide;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
// for all items or ref slides (items and menus)
// within this slide_ref passed for this menu
for (var i=1; i<nSlideCount+1; i++) {
// movieclip for each menu item
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
curr_item._x = x;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
// item properties assigned from ref
curr_slide = ArtAPI.GetSlideInfo(i);
next_slide = ArtAPI.GetSlideInfo(i+1);
prev_slide = ArtAPI.GetSlideInfo(i-1);
curr_item.variables = i;
curr_item.name.text = curr_slide.strTitle;
// item submenu behavior for rollover event
if ((curr_slide.nLevel == 0)&&(next_slide.nLevel == 1)){
// open a submenu
curr_item.slide_ref = curr_slide;
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width - 5;
var y = this._y + 5;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.slide_ref);
// show a hover color
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
}else{
slideName == "item"
curr_item.arrow._visible = false;
// close existing submenu
curr_item.onRollOver = curr_item.onDragOver = function(){
curr_menu.submenu_mc.removeMovieClip();
// show a hover color
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
}
curr_item.onRollOut = curr_item.onDragOut = function(){
// restore color
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
// any item, menu opening or not can have actions
curr_item.onRelease = function(){
//;
ArtAPI.PlaySlideNum(Number(this.variables))
//Actions[this.action](this.variables);
CloseSubmenus();
};
} // end for loop
};
// create the main menu, this will be constantly visible
CreateMainMenu = function(x, y, depth, menu_ref){
// generate a menu list
GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_ref.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();
};
// This actions object handles methods for actions
// defined by the ref called when a menu item is pressed
CreateMainMenu(10, 10, 0, this);
//getURL("javascript:alert('slidecount = "+nSlideCount+"')");
//getURL("javascript:alert('msg')");
Regards
TCDown