Re: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Hi, Without looking at your exact dataProvider with a simple Application, I can't help much. I got this to work yesterday using @enabled = false on the node. But the ex4 implementation various on 'WHERE' you are trying to set the enabled of the node. Can you post a simple mxml Application? Mike On Tue, Jun 3, 2008 at 10:21 AM, Andrew Price [EMAIL PROTECTED] wrote: I am new to flex myself but is it not just. menuDown.enabled=true or menuDown.enabled=fasle -Original Message- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *bc24fl *Sent:* 03 June 2008 14:56 *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, bc24fl [EMAIL PROTECTED] wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks. -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Graphix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'.
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
What is null? Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 11:15 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I just tried that and get an error: Cannot access a property or method of a null object reference Thanks for helping. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt [EMAIL PROTECTED] wrote: Ah, no I looked at the history and that was a different thread, probably confused others as well. Ok, try this: var xmlMenuItem:XML = myMenuData..menuItem.(attribute(id)==menuDown)[0]; [EMAIL PROTECTED] = false; Tracy From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 9:56 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , bc24fl bc24fl@ wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks.
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Is this the thread where you are not able to use the normal method of doing this via the dataProvider, but must have some way to do it via the instantiated elements? Because you are trying to automate unit testing or something? Because programatically disabling a particular menu item is easy. Just get a reference to the menu item node and set the enabled attribute. Is that not acceptable to you? Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 9:56 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , bc24fl [EMAIL PROTECTED] wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks.
Re: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Hi stranger bc24fl, Mike Schmalle had proposed you the exact solution, that we are currently using within our project based on Flex 2 SDK to enable/ disable menu items in MenuBar component. I do not understand without looking at your code, what is going on wrong with your MenuBar. Can you post a dummy sample of the code online to illustrate your problem? SWF with View source option enabled would be nice. ps Why do you post anonymously to this list, BTW? I would like to reference you by your name ;) -- -- Med venlig hilsen / Best regards Andriy Panas [EMAIL PROTECTED] On 03/06/2008, bc24fl [EMAIL PROTECTED] wrote: I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, bc24fl [EMAIL PROTECTED] wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks.
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Ah, no I looked at the history and that was a different thread, probably confused others as well. Ok, try this: var xmlMenuItem:XML = myMenuData..menuItem.(attribute(id)==menuDown)[0]; [EMAIL PROTECTED] = false; Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 9:56 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , bc24fl [EMAIL PROTECTED] wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks.
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
I am new to flex myself but is it not just. menuDown.enabled=true or menuDown.enabled=fasle -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: 03 June 2008 14:56 To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, bc24fl [EMAIL PROTECTED] wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks.
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
This won't work: myMenuData.menuitem.(@id==menuDown)[EMAIL PROTECTED] = false; You need to use the attribute syntax as in my example. Tract From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 10:52 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 Fair enough. Here is the code: The menu is created using: public var myMenu:Menu; //myMenu is globally created 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); = After this I add a few event handlers specific to the menu Then I add a switch statement to test what item was clicked. When the item Lock / Unlock is selected I ouput an Alert to make sure It is working correctly. Directly after the Alert I run the following: === myMenuData.menuitem.(@id==menuDown)[EMAIL PROTECTED] = false; // I ALSO TRIED myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown[0],false) ; === The data is statically defined in mxml like so: = !-- Define the menu data. -- 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 === I hope this is enough info. If someone has another example using a different data source please post. I don't have to use an XML formatted data. Thanks for the help. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Without looking at your exact dataProvider with a simple Application, I can't help much. I got this to work yesterday using @enabled = false on the node. But the ex4 implementation various on 'WHERE' you are trying to set the enabled of the node. Can you post a simple mxml Application? Mike On Tue, Jun 3, 2008 at 10:21 AM, Andrew Price [EMAIL PROTECTED] wrote: I am new to flex myself but is it not just. menuDown.enabled=true or menuDown.enabled=fasle -Original Message- *From:* flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] *On Behalf Of *bc24fl *Sent:* 03 June 2008 14:56 *To:* flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com *Subject:* [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 I'm really struggling for help. We have done everything to try and get a solution to this problem including: 1. Posting on public forums / mailing lists 2. Purchased books on AS3 and Flex 3. Signed up for a year subscription to Lynda.com 4. Purchased support from experts-exchange.com 5. Purchased support directly from Adobe where supposedly it's 3 day response (no resolution) and we have received no response for a week (business days). What in the world am I doing wrong? This question doesn't appear to be rocket science as I've done this (enable/disable menu items) in many other programming languages. As you can see I have exhausted every (that I know of) resource. What else am I to do? My employer is upset and now considering dropping the language altogether and I don't want that. Any advice would BE MUCH APPRECIATED. End rant. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com flexcoders%40yahoogroups.com, bc24fl bc24fl@ wrote: I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false, however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown,false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks. -- Teoti Graphix
RE: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Yes, it can. Valdhor's example works for me. There is something going on with the programmatic instantiation of the menu, it dissapears on click unless it gets recreated in the handler. That is just a bug and not necessary to demonstrate the technique of disabling a menu item. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bc24fl Sent: Tuesday, June 03, 2008 12:32 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0 Ok I think I'm getting closer. In your example you create the menu when the user clicks but in my code the menu has already been created globally. Can the XML data be changed dynamically once the menu has already been create? --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , valdhor [EMAIL PROTECTED] wrote: OK, this is fairly buggy but it does show you can gray out a menu item from actionscript (Check the Down submenu item after clicking the Lock / Unlock menu item). I will leave the bug fixes and extras to you :-)... ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute creationComplete=onComplete(event) mx:Script ![CDATA[ import mx.events.MenuEvent; import mx.events.FlexEvent; import mx.controls.Menu; import mx.controls.Alert; public var myMenu:Menu = new Menu(); public function onComplete(event:FlexEvent):void { myMenu = Menu.createMenu(this, myMenuData, false); myMenu.labelField=@label; myMenu.show(100,100); myMenu.addEventListener(MenuEvent.ITEM_CLICK, menuClickHandler); } private function menuClickHandler(event:MenuEvent):void { if(event.label == Lock / Unlock) { myMenuData..menuitem.(attribute(id)==menuDown)[EMAIL PROTECTED] = false; myMenu = Menu.createMenu(this, myMenuData, false); myMenu.labelField=@label; myMenu.show(100,100); } } ]] /mx:Script mx:XML format=e4x id=myMenuData root menuitem id=menuDrill label=Drill =gt; 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 /mx:Application
Re: [flexcoders] Re: Enable / Disable Flex Menu Items Programmatically using AS 3.0
Just curious but, have you traced what the value of; myMenuData.menuDrill.menuDown is? Would be interesting to know what you are trying to set. Mike On Mon, Jun 2, 2008 at 2:44 PM, bc24fl [EMAIL PROTECTED] wrote: Just tried it but did not work. Any ideas? --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, Have you tried; myMenu.dataDescriptor.setEnabled(myMenuData.menuDrill.menuDown[0],false); Mike On Mon, Jun 2, 2008 at 12:38 PM, Marty Pitt [EMAIL PROTECTED] wrote: this is extremely close to what I'm trying to do. (I posted here earlier today looking for a solution!) You can modify the dataProvider of the XML, setting the @enabled attribute, which will cause the menu to update. Eg.,. myMenuData..menuitem.(@id==menuUp)[EMAIL PROTECTED] = false ...will disable the menuUp entry. If you're trying to get access directly to the menu instance, then I'm afraid I don't know the answerthat's what my post was about this morning. (I'm trying to get a reference for a unit test so I can do an assertion on the enabled property of the menuItem itself.) Hope that helps Marty - Original Message From: bc24fl [EMAIL PROTECTED] To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com Sent: Monday, June 2, 2008 4:29:11 PM Subject: [flexcoders] Enable / Disable Flex Menu Items Programmatically using AS 3.0 I have the following XML data defined in my app: = !-- Define the menu data. -- 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 === I can statically disable one of the items by setting enabled=false , however I need to disable the item by using Action Script 3.0. I've tried using dataDescriptor like so but it does not work: === myMenu.dataDescript or.setEnabled( myMenuData. menuDrill. menuDown, false); === I've posted this on a few forums and haven't received a solution. I hope I can find one here. Any help would be much appreciated. Thanks. -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Grahix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'. -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Grahix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'.