Hi,
I have been working through senocular’s excellent tutorial on building an XML Driven menu and trying to adapt it to an Articulate ArtAPI.
I having real trouble with the second level menu’s and wondered if anyone on here has the time to have a look and see what I have done wrong.
I am using CS4 and have posted a copy of the files to www.cblendedlearning.com/menu_sample.zip
If you need further explanations of what I am trying to achieve or what I have done please ask.
The actionscript I have used is below as well.
Regards TCDown
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')");