I have an tree component that is populated via XML. There are branch nodes and child nodes for each branch. This is a user interface for an elearning course. The branch nodes/folders in the tree component are for course sections and the child/leaf nodes for each are the content topics. each have a url attribute with a path to the appropriate content swf. The branch nodes/folders in the tree component do nothing when they are clicked on, as intended.
I also have previous/next buttons. They basically just navigate between leaf nodes. However, if the currently playing topic/leaf node is the first underneath a branch/folder, and I click on the ‘previous’ button, nothing happens. How can I set this thing to ‘skip over’ branch nodes? Here is the relevant code (the tree change listener, and the previous/next button event handlers:
var treeClickListener:Object = new Object();
treeClickListener.change = function() {
var item = menu_ctr.selectedItem;
var earl = item.attributes.url;
nowPlaying = menu_ctr.selectedItem;
if(earl) { //the var name 'earl' is equal to 'url' in xml, because url is a keyword in flash so shouldn't use it...
content_cld.contentPath = earl;
lessonName_txt.text = nowPlaying.attributes.unit + " : " + nowPlaying.attributes.lesson;
//added 060208 - close the menu when user selects an item
hideMenu();
//set the 'demo' indicator if the content is a demo
if (nowPlaying.attributes.demo == "yes")
{
demo_mc.gotoAndStop("on");
} else {
demo_mc.gotoAndStop("off");
} cefe
}
}
menu_ctr.addEventListener("change",treeClickListener);
/***********************************************
* Navigation Buttons
***********************************************/
next_btn.onRelease = function()
{
if (!nowPlaying.nextSibling)
{
return;
} else
{
content_cld.contentPath = nowPlaying.nextSibling.attributes.url;
nowPlaying = nowPlaying.nextSibling;
lessonName_txt.text = nowPlaying.attributes.unit + " : " + nowPlaying.attributes.lesson;
if (nowPlaying.attributes.demo == "yes")
{
demo_mc.gotoAndStop("on");
} else {
demo_mc.gotoAndStop("off");
}
}
}
previous_btn.onRelease = function()
{
if (!nowPlaying.previousSibling)
{
trace("No previousSibling");
} else
{
content_cld.contentPath = nowPlaying.previousSibling.attributes.url;
nowPlaying = nowPlaying.previousSibling;
lessonName_txt.text = nowPlaying.attributes.unit + " : " + nowPlaying.attributes.lesson;
if (nowPlaying.attributes.demo = "yes")
{
demo_mc.gotoAndStop("on");
} else {
demo_mc.gotoAndStop("off");
}
}
}
Here is an excerpt from the XML file:
<tree>
<folder label="PowerPoint-Based Movies">
<link label="Subtopic One" unit="Unit One" lesson="Lesson One" url="content/SWFfromPPTslides/PPTSlide_RUSS_TEST_skin.swf" />
<link label="Subtopic Two" unit="Unit Two" lesson="Lesson Two" url="content/mark1.swf" />
</folder>
<folder label="Captivate-Based Movies">
<link label="Subtopic One" unit="Unit Three" lesson="Lesson Three" demo="yes" url="content/SWFofdesktop/test32_demo_skin.swf" />
<link label="Subtopic Two" unit="Unit Four" lesson="Lesson Four" demo="yes" url="content/mark2.swf" />
<folder label="Subfolder Example">
<link label="Subtopic One" url="#" />
<link label="Subtopic Two" url="#" />
</folder>
</folder>
</tree>