Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / June 2005



Tip: Looking for answers? Try searching our database.

attaching movie clips to MenuBar menus

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pkids - 29 Jun 2005 00:42 GMT
I'm running MX Pro 2004 on Windows Xp.
I've created a menu bar w/ the MenuBar component, including drop-down menus.
Here's my script for one of the menu items:

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"});

Now I want to tell those menu items to load a SWF into holder_mc, my empty
movie clip on the stage. I know how to do this using Behaviors, but in
ActionScript, I don't know how to do this. I've searched for info on this
(code, or a tutorial) in several places but can't find it. Would appreciate
direction on this issue. Thanks!
.:}x-=V!P=-x{:. - 29 Jun 2005 21:42 GMT
have you exported for actionscript your instances in the library ?
pkids - 30 Jun 2005 00:43 GMT
Thank you for responding! re: exporting for AS, I didn't see where that was an
option. That is, I'm using the MenuBar component, so that's all that's in my
Library. I assumed the instances were named since they are given instance names
in the script below. I managed to attach a trace to it so something is working.
I don't understand why I can't find anything to help me w/ this, since the
logical thing a person would do with menu items is cause them to load a webpage
or movie.

I fully admit that I'm a total newbie and that if I were to take the AS class,
I would probably know how to do this. But I'm working for a nonprofit that
doesn't have the funds just yet to send me to the class, so I'm fishing for
*anything* that will help me.

thank you again for responding -- I hope you can point me in the right
direction --
myIP - 30 Jun 2005 15:36 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.