bc24fl
asked on
Programatically Enable or Disable Menu Items in Flex 3
Attach is the code snippet I'm using. I've tried everything to programmatically disable / enable a menu item like "Down" but nothing works for me.
Any ideas would be much appreciated.
Any ideas would be much appreciated.
<mx:XML format="e4x" id="myMenuData">
<root>
<menuitem id="menuDrill" label="Drill =>" >
<menuitem id="menuDown" label="Down" toggled="false" enabled="true"/>
<menuitem id="menuUp" label="Up" toggled="false" enabled="true"/>
</menuitem>
<menuitem type="separator"/>
<menuitem label="Lock / Unlock" type="check" toggled="false"/>
<menuitem type="separator"/>
<menuitem label="Reset Graph" toggled="false"/>
</root>
</mx:XML>
============Action Script Code===================
var pt:Point = new Point(event.localX, event.localY);
myMenu = Menu.createMenu(null, myMenuData, false);
pt = event.target.localToGlobal(pt);
myMenu.labelField="@label";
myMenu.show(pt.x, pt.y);
ASKER
There isn't an example of what I'm looking for there.
If you look through the menu items on your browser you will notice some menu items grayed out and unclickable. This is what I want to do but in flex using actionscript 3.0.
Thanks.
If you look through the menu items on your browser you will notice some menu items grayed out and unclickable. This is what I want to do but in flex using actionscript 3.0.
Thanks.
Hi,
I thought that the example at the end of the proposed page (scrolling all page down there) could serve you ... sorry!
Best regards,
Raisor
I thought that the example at the end of the proposed page (scrolling all page down there) could serve you ... sorry!
Best regards,
Raisor
ASKER
Thanks for the help anyway. I'll google something up and if I find the solution post it here.
Hi,
I'd be glad to see the solution that you're up to post ... it might give me an impression of what you were really looking for!
Best regards,
Raisor
I'd be glad to see the solution that you're up to post ... it might give me an impression of what you were really looking for!
Best regards,
Raisor
Have you tried
<menuitem label="MenuItem A" enabled="False">
<menuitem label="MenuItem A" enabled="False">
ASKER
What I'm really looking for is what DanRollins posted but instead of doing this:
<menuitem label="MenuItem A" enabled="False">
I want to do the same in ActionScript or Programmatically as I mention in my post. Something like
myMenu.myMenuItems.setEnab le("DownMe nuItem",fa lse);
I hope this is clear enough.
Thanks.
<menuitem label="MenuItem A" enabled="False">
I want to do the same in ActionScript or Programmatically as I mention in my post. Something like
myMenu.myMenuItems.setEnab
I hope this is clear enough.
Thanks.
ASKER
Wow this is my first question here on EE and no solutions to what I believe is pretty straight forward request from any programming language. Does EE have paid consultants?
Admin, when I posted this I didn't include "actionscript" group in the zones. Is there a way to add this?
Admin, when I posted this I didn't include "actionscript" group in the zones. Is there a way to add this?
ASKER
We signed up for flex developer support through Adobe. Flex 3.0 is relatively new and probably why we couldn't get a solution to our problem. When our annual support plan expires I'll give experts-eschange another shot. Thanks to all who responded.
Thanks.
Thanks.
Have you looked at the
MenuBar control
http://livedocs.adobe.com/flex/3/html/help.html?content=Menus_9.html
It appears that "enabled" is an available attribute:
http://livedocs.adobe.com/flex/3/html/help.html?content=menucontrols_3.html#410755
Perhaps you need to set
enabled="true"
when you define the menuitem, so you can toggle it to "false" later.
=-=-=-=-=-=-=-=-=
As a PageEditor for another section, I could add "Macromedia Flash" to your list of sections, but I'd need to remove one of the existing ones (max 3). Do you want me to remove this Q from "Miscellaeous Programming" and add it to "Macromedia Flash" ?
MenuBar control
http://livedocs.adobe.com/flex/3/html/help.html?content=Menus_9.html
It appears that "enabled" is an available attribute:
http://livedocs.adobe.com/flex/3/html/help.html?content=menucontrols_3.html#410755
Perhaps you need to set
enabled="true"
when you define the menuitem, so you can toggle it to "false" later.
=-=-=-=-=-=-=-=-=
As a PageEditor for another section, I could add "Macromedia Flash" to your list of sections, but I'd need to remove one of the existing ones (max 3). Do you want me to remove this Q from "Miscellaeous Programming" and add it to "Macromedia Flash" ?
Hi,
I'm definitly sorry not having been able to point you to the right direction with your question ... all that I found out is, that a guy named Dirk has built a blog and seems to be a genius at the requested topic ... you might like to contact him directly through the contact data of his blog: http://www.richinternet.de/blog/
Hope that this hint leads you to the desired result!
Best regards,
Raisor
I'm definitly sorry not having been able to point you to the right direction with your question ... all that I found out is, that a guy named Dirk has built a blog and seems to be a genius at the requested topic ... you might like to contact him directly through the contact data of his blog: http://www.richinternet.de/blog/
Hope that this hint leads you to the desired result!
Best regards,
Raisor
So did anybody figure out how to do this? I too need to do what bc24fl wants to do. I have a menubar component that I generate with XML. Several of my options rely on an Internet connections (it's in an AIR app). I have a function that listens for changes on a URLMonitor object. So when there is no net connection I disable some things. I need to disable options in my menu. I know I need to set enabled="false". What I don't know is how to access it from my AS code. So I want to do something like:
MyMenusIDName.SubMenuIdNam e.enabled = false;
Anybody??
MyMenusIDName.SubMenuIdNam
Anybody??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the effort but I can't get this to work in Flex/AS 3.0.
I believe at least one solution here is to set the enable property on menuitem in the source XML file to a bindable dynamic variable and control the value of that variable using actionscript.
e.g.
SCRIPT:
[bindable]
private var toggleSwitch:Boolean = false;
private function controlMenu(event:Event):v
if ( event.currentTarget.select
toggleSwitch = true;
}else{
toggleSwitch = false;
}
}
MXML: (XML Node of menu data provider)
<menuitem id="menuDown" label="Down" toggled="false" enabled="{toggleSwitch}"/>
you might like to try the sample at http://livedocs.adobe.com/flex/3/langref/mx/controls/Menu.html
If that sample also doesn't work, we should have a look at you environment.
Best regards,
Raisor