The following code should work for you. Put the code in the main TimeLine.
Name your menuBar?s component instance name to ?topMenuBar?. If you are using
a Loader component or a movieClip holder give it an instance name of
?holder_mc?. When the user selects an item from the menuBar, Holder_mc will
load a image that resides in the same directory as the application (the last
case statement has a quote that will load a image from a folder called
?grosspictures?). I have the code set up for a Loader Component. If you are
using a movieClip holder unquote the loadMovie( ) line and quote out or delete
the ContentPath line. Do this for all of the other case statements. I hope
this helps. Post if you need more help.
var menu = topMenuBar.addMenu("Treatment");
menu.addMenuItem({label:"Bacterial", instanceName:"bacTreatInstance"});
menu.addMenuItem({label:"Viral", instanceName:"viralTreatInstance"});
menu.addMenuItem({label:"Fungal", instanceName:"fungalTreatInstance"});
menu.addMenuItem({label:"Other", instanceName:"otherTreatInstance"});
listenerObject = new Object();
listenerObject.change = function(eventObject)
{
switch(eventObject.menuItem.attributes.instanceName)
{
case("bacTreatInstance"):
holder_mc.contentPath = "bacTreatPic.swf"//or it can be a jpg,
"viralTreatPic.jpg"
break;
case("viralTreatInstance"):
holder_mc.contentPath = "viralTreatPic.swf"
//loadMovie("viralTreatPic.jpg", holder_mc);//use this stlye for movieclip
holder(non-component)!!!
break;
case("fungalTreatInstance"):
holder_mc.contentPath =
"fungalTreatPic.swf"//"grosspicutres/fungalTreatPic.swf"
break;
default:
break;
}
}
topMenuBar.addEventListener("change", listenerObject);
pkids - 30 Jun 2005 19:40 GMT
myIP -- WOW. It worked!!! You are a lifesaver! Not only did it work, but I can
also study the code -- I was happy to see I had been on the right track, but I
had not encountered the "case" keyword before. Our nonprofit has applied for
some funding that, if received, a small portion of it would pay for me to get
ActionScript training. But in the meantime, your help got me over a roadblock
so I can finish our current project. All that to say THANK YOU so very much --
I really appreciate your help!
myIP - 30 Jun 2005 20:29 GMT
Jeez?thanks for the last post! I am glad I was a help.