5 Replies Latest reply on Apr 5, 2011 3:02 PM by joan_lafferty

    Menu.createMenu is not working in flex 4.1.

    karthee

      Hi,

       

      I have created a menu bar with menu item using flex 4. My problem is that the meubar is not clickable on left and right side. How to make it clickableon both sides? For this problem i have found a solution by clicking a button using Menu.createMenu but it is not working in flex 4.1. can anyione help me with this?

       

      Thanks,

      Karthick K.

        • 1. Re: Menu.createMenu is not working in flex 4.1.
          joan_lafferty Adobe Employee

          I am not sure what you mean when you say that you cannot click on the left and

          right side. Are you saying that clicking on some menu items in the MenuBar does not bring down the menus?

          Please post some sample code. I'm not aware of us breaking anything regarding Menus or MenuBar in Flex 4.1. This code wasn't touched too much, but, we may have introduced a bug fix.

           

          Thanks,

          Joan Lafferty

          Flex SDK Quality Engineer

          • 2. Re: Menu.createMenu is not working in flex 4.1.
            karthee Level 1

            find my code below,

             

            <?xml version="1.0" encoding="utf-8"?>

             

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx">
               
                <fx:Script>

             

                    <![CDATA[
                       
                        import mx.controls.Menu;
                        import mx.events.FlexEvent;
                        import mx.events.MenuEvent;
                       
                        protected var menu1:Menu;
                       
                        protected function showMenu():void
                           
                        {
                           menu1 = Menu.createMenu(null, menuItem, false);
                            menu1.labelField="@label";
                            menu1.iconField="@icon";
                            menu1.show(0, 35);

                        }
                       
                    ]]>
                   
                </fx:Script>
                <fx:Declarations>
                    <fx:XML format="e4x" id="menuItem">
                        <root>
                            <menuitem label="MenuItem A">
                                <menuitem label="File" icon="topIcon">
                                    <menuitem label="New"/>
                                    <menuitem label="Open"/>
                                    <menuitem label="Save" icon="top2Icon"/>
                                    <menuitem label="Save as..."/>
                                    <menuitem label="Close"/>
                                    <menuitem label="Print"/>
                                    <menuitem type="separator"/>
                                    <menuitem label="Quit"/>
                                </menuitem>
                                <menuitem label="Edit">
                                    <menuitem label="Undo"/>
                                    <menuitem label="Redo"/>
                                    <menuitem type="separator"/>
                                    <menuitem label="Cut"/>
                                    <menuitem label="Copy"/>
                                    <menuitem label="Paste"/>
                                </menuitem>
                               
                                <menuitem label="View"/>
                                <menuitem label="Document" icon="top1Icon"/>
                                <menuitem label="Tools">
                                    <menuitem label="BasicToolsSubToolBar">
                                        <menuitem label="SelectMenuItem"/>
                                        <menuitem label="HandMenuItem"/>
                                        <menuitem label="ZoominMenuItem"/>
                                        <menuitem label="ZoomDragMenuItem"/>
                                    </menuitem>
                                    <menuitem label="AnalysisToolsItem"/>
                                </menuitem>
                                <menuitem label="Window"/>
                                <menuitem label="Help"/>
                            </menuitem>
                            <menuitem label="MenuItem B"/>
                            <menuitem label="MenuItem C"/>
                            <menuitem label="MenuItem D"/>
                        </root>
                       
                    </fx:XML>
                   
                </fx:Declarations>
               
                <s:Panel title="Menu Control Example" width="553" height="238">
                    <s:Button x="10" y="174" label="Show Menu" click="showMenu()"/>
                </s:Panel>
               
            </s:Application>

             

            The above code is not working in Flash builder 4 sdk used is 4.1 especially the code snippet in red.

            MenuBar.JPG

             

            Thanks,

            Karthick K..

            • 3. Re: Menu.createMenu is not working in flex 4.1.
              joan_lafferty Adobe Employee

              I tried your code snippet with Flex SDK 4.1. I click the button labeled "Show Menu" and a Menu shows up. The submenus work too. Is this not what you are seeing?

               

              As for the right/left sides of the MenuBar not being clickable, I believe this is the intended behavior. Only the MenuItem is clickable. These edges are considered the 'background'. I think you'd need to do a custom skin or subclass MenuBar to have the MenuItems lay out different.

               

              Joan

              • 4. Re: Menu.createMenu is not working in flex 4.1.
                karthee Level 1

                Hi Joan,

                 

                I get the following errors,

                 

                menu1 = Menu.createMenu(null, menuItem, false); - 1061: Call to a possibly undefined method createMenu through a reference with  static type Class.
                menu1.labelField="@label"; - 1119: Access of possibly undefined property labelField through a reference with  static type Menu.
                menu1.iconField="@icon"; -1119: Access of possibly undefined property iconField  through a reference with static type Menu.

                menu1.show(0, 35); - 1061: Call to a possibly undefined method show through a  reference with static type Menu.

                 

                FYI, i am using flash builder 4 and flex sdk is set to 4.1.


                Thanks,

                Karthick K.

                • 5. Re: Menu.createMenu is not working in flex 4.1.
                  joan_lafferty Adobe Employee

                  Hi Karthick,

                   

                  I just can't reproduce your issue. I'm guessing something is corrupted in your project and so when you compile, the properties of the Menu class aren't being recognized.

                   

                  Maybe you can file a bug in JIRA : http://bugs.adobe.com/flex

                   

                  In the bug, attach your Flex project, if possible.

                   

                  I tested with Flash Builder 4 and SDK 4.1 and didn't see the issue you are seeing using the code you posted in the thread.

                   

                  Joan