This won't work:

myMenuData.menuitem.(@id=="menuDown")[EMAIL PROTECTED] = "false";

You need to use the attribute syntax as in my example.

 

Tract

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of bc24fl
Sent: Tuesday, June 03, 2008 10:52 AM
To: [email protected]
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 [email protected] <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:* [email protected]
<mailto:flexcoders%40yahoogroups.com> 
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] *On
> > Behalf Of *bc24fl
> > *Sent:* 03 June 2008 14:56
> > *To:* [email protected]
<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 [email protected]
<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, LLC
> http://www.teotigraphix.com <http://www.teotigraphix.com> 
> 
> Teoti Graphix Blog
> http://www.blog.teotigraphix.com <http://www.blog.teotigraphix.com> 
> 
> You can find more by solving the problem then by 'asking the
question'.
>

 

Reply via email to