I tried it on another menu test I have and didn't get a reference error,
but I did have to make one small change:
 
dataDescriptor.setToggled(_menuXML..menuItem.(@label=="Foo")[0], false);

 
________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sascha
Sent: Monday, April 02, 2007 1:44 AM
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?



Thanks Alex! How do you get the condition check working? If I try to use
() in the E4x I always get a ReferenceError: Error #1065: Variable
@label is not defined. i.e.

trace(_menuXML..menuitem.(@label=="Foo").toString());

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Monday, April 02, 2007 15:25
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?

Should be something like:

dataDescriptor.setToggled(_menuXML..menuItem.(@label=="Foo"), false);

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sascha
Sent: Sunday, April 01, 2007 8:16 AM
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?

Alex, using E4x from there on sounds good but I still haven't figured it
out complety. Here's something similar to the XML I'm using for my menu
..

private var _menuXML:XMLList =

                <>

                                <menuitem label="File">

                                                <menuitem label="Exit"
data="exit"/>

                                </menuitem>

                                <menuitem label="View">

                                                <menuitem label="Foo"
type="check" toggled="true" data="foo"/>

                                                <menuitem label="Jon"
type="check" data="jon"/>

                                </menuitem>

                                <menuitem label="Help">

                                                <menuitem label="Doe"
data="doe"/>

                                </menuitem>

                </>;

How would you access for example Foo to toggle the item to false via the
dataDescriptor?

Thanks a lot for your help!

Sascha

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Sunday, April 01, 2007 15:50
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?

>From AS, you use E4x to change the toggled attribute in the XML.  When
the menu is created it will read the new toggled property.

If you're still stuck, post what you have so we can see how you're
thinking about the problem.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sascha
Sent: Saturday, March 31, 2007 10:21 PM
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?

Thanks for pointing me in the right direction Alex! But how do you
access the specific menu item from there on? I can't figure out how the
menu item in the XML is reached by the isToggled or setToggled method.
Would be great if you can give me a small example.

Sascha

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Sunday, April 01, 2007 02:53
To: [email protected]
Subject: RE: [flexcoders] Toggling Menu Item?

The dataDescriptor has an isToggled method that is passed the data item
and returns true or false.  By default, it looks for a toggled="true"

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sascha
Sent: Friday, March 30, 2007 11:48 PM
To: [email protected]
Subject: [flexcoders] Toggling Menu Item?

Hi list,

Since I cannot find any information about this anywhere else ...

How do you toggle a (flex 2 ) check/radio menu item from ActionScript?
Say I use an XML object to populate my MenuBar with ...

private var _menuXML:XMLList =

                <>

                                <menuitem label="Foo">

                                                <menuitem label="Bar"
type="check" data="bar"/>

                                </menuitem>

                </>;

var _menubar:MenuBar = new MenuBar();

_menubar.dataProvider = _menuXML;

... how are you able to toggle the check item on/off with ActionScript?
I don't see any way to reach the specific item via MenuBar properties.

Thanks in advance for any tips!

Sascha

 

Reply via email to