Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-16-2004, 10:48 PM   #1
rbb
Registered User
 
rbb's Avatar
 
Join Date: Feb 2002
Location: melbourne
Posts: 20
Send a message via ICQ to rbb
Default Targetting the top level of menu bars?

Hi,

I've got a menu bar with a few drop down sub-menus, which I can target fine. But the mast item on the top level of the menu bar, I want to be "exit", but it will have no sub-menu. How do I go about targetting items on the top level of the menu bar?

Thanks,

rbb.
rbb is offline   Reply With Quote
Old 04-17-2004, 01:21 PM   #2
yorkeylady
Registered User
 
Join Date: Jan 2003
Posts: 397
Send a message via ICQ to yorkeylady Send a message via AIM to yorkeylady Send a message via Yahoo to yorkeylady
Default

Still learning about this myself.
Here's my best guess.
myMenu is the instance name of the Menu Component, (Not the MenuBar which creates the drop down instances)
ActionScript Code:
myMenu.onPress= function(){   // insert your code here }

Last edited by CyanBlue; 02-10-2005 at 10:00 PM.. Reason: AS tag is applied
yorkeylady is offline   Reply With Quote
Old 09-03-2004, 09:39 AM   #3
Jotun75
Registered User
 
Join Date: Sep 2004
Posts: 9
Default Targeting menubar items

Hi!

I have an undocumented solution to how to target the menubar items.

Goes like this.
ActionScript Code:
myMenubar.addMenu("start") myMenubar.addMenu("help")
ok now my menubar has to menuitems with no dropdown menu.

If you want to target an onPress on just the menubar item instead of having a dropdown menu on it, you do as this -->

The target to "start" is myMenubar.mbItem200
so simply assign
ActionScript Code:
myMenubar.mbItem200.onPress(){         //whatever action u want }
Try to guess what this targets
ActionScript Code:
myMenubar.mbItem201.onPress(){       //whatever action u want }
Yepp, it targets the "help" item.

So in short the menubar item is named from start to end mbItem200....mbItem20n.
Strange that MM dont have this in their docs, go figure.


I know my english aint good, sorry for that.

Last edited by CyanBlue; 02-10-2005 at 10:01 PM.. Reason: AS tag is applied
Jotun75 is offline   Reply With Quote
Old 09-11-2004, 10:24 AM   #4
pigpen
Registered User
 
Join Date: Nov 2002
Posts: 22
Default could'nt get that to work

I'm having trouble with the mbItem200 method you explained. Can you attach a fla example?

thanks.
pigpen is offline   Reply With Quote
Old 09-15-2004, 09:29 AM   #5
Jotun75
Registered User
 
Join Date: Sep 2004
Posts: 9
Default Sure ! Here is the file

Quote:
Originally Posted by pigpen
I'm having trouble with the mbItem200 method you explained. Can you attach a fla example?

thanks.
here is the file
Attached Files
File Type: zip mbar.zip (363.4 KB, 172 views)

Last edited by Jotun75; 09-15-2004 at 09:45 AM..
Jotun75 is offline   Reply With Quote
Old 09-15-2004, 01:08 PM   #6
pigpen
Registered User
 
Join Date: Nov 2002
Posts: 22
Default

Thanks! Very interesting. No event listeners needed. Thats why I couldn't get it to work using your method because I was added listeners by mistake. Makes sense now.

I'm curious. How did you find out about this mbItem? Yeah you would think MM would have this in thier docs.
pigpen is offline   Reply With Quote
Old 09-15-2004, 01:20 PM   #7
Jotun75
Registered User
 
Join Date: Sep 2004
Posts: 9
Default Strange that they dont document this

I found it out by chance while debugging. I was curious about the structure and objects created at runtime, so when I did a closer look at the objects on the component in the debugger I discovered the pattern in the reference mbItem200,mbItem201,mbItem202 and so on matched my actual menubar items.

Last edited by Jotun75; 09-15-2004 at 01:36 PM..
Jotun75 is offline   Reply With Quote
Old 09-16-2004, 06:05 AM   #8
pigpen
Registered User
 
Join Date: Nov 2002
Posts: 22
Default

Nice. That reminds me to use the debugger more often, especially when using these often under-documented components. Thanks again.^^
pigpen is offline   Reply With Quote
Old 02-10-2005, 06:58 PM   #9
chrispix
Registered User
 
Join Date: Feb 2005
Posts: 9
Default syntax

Thanks for this! You saved me a ton of work. One correction to the syntax of your example:
Code:
myMenubar.mbItem200.onPress(){
        //whatever action u want
}
Try to guess what this targets :)
myMenubar.mbItem201.onPress(){
      //whatever action u want
}
should be

Code:
myMenubar.mbItem200.onPress = function() {
        //whatever action u want
}
Try to guess what this targets :)
myMenubar.mbItem201.onPress() = function() {
      //whatever action u want
}
chrispix is offline   Reply With Quote
Old 01-20-2009, 05:54 PM   #10
mcarey
Registered User
 
Join Date: Jan 2003
Location: NJ USA
Posts: 14
Default another note which might help others...

When I attempted this workaround, I got a compiler error if I did not include a level scope when targeting the menubar component.

So...
Code:
myMenubar.mbItem201.onPress() = function() { ...
produced this error:
Code:
There is no property with the name 'mbItem201'.

but
Code:
_level0.myMenubar.mbItem201.onPress() = function() { ...
produced no error and assigned the click behavior successfully.

Thanks for the nod in the right direction!
mcarey is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.