That works. Thanks.

To: flexcoders@yahoogroups.com
From: aha...@adobe.com
Date: Thu, 8 Mar 2012 14:38:38 -0800
Subject: Re: [flexcoders] Flex Menu.createMenu on mouseDown issue


















 



  


    
      
      
      


Did you try callLater on createAndhow?





On 3/8/12 9:30 AM, "Philip Smith" <loudj...@hotmail.com> wrote:



 

 

 

   



Substitute this button code to see the menu create fail:



<!--- mouse down fails to show menu -->

        <s:Button id="myButton" 

                  label="Open Menu" 

                  mouseDown="createAndShow();"/>



To: flexcoders@yahoogroups.com

From: loudj...@hotmail.com

Date: Thu, 8 Mar 2012 17:27:45 +0000

Subject: RE: [flexcoders] Flex Menu.createMenu on mouseDown issue



 

 

 

   

The menu doesn't open. And 'mouseDown' is required in the context of the app. 
Any ideas, Alex?



Here's the test code:



<?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" width="400" 
height="300">

    <fx:Declarations>

        <!-- Define the menu data. -->

        <fx:XML format="e4x" id="myMenuData">

            <root>

                <menuitem label="MenuItem A" >

                  ! ;  <menuitem label="SubMenuItem A-1" enabled="false"/>

                    <menuitem label="SubMenuItem A-2"/>

                </menuitem>

                <menuitem label="MenuItem B" type="check" toggled="true"/>

                <menuitem label="MenuItem C" type="check" toggled="false"/>

                <menuitem type="separator"/>     

                <menuitem label="MenuItem D" >

                    <menuitem label="SubMenuItem D-1" type="! radio" 

          &! nbsp; &n bsp;                 groupName="one"/>

                    <menuitem label="SubMenuItem D-2" type="radio" 

                              groupName="one" toggled="true"/>

                    <menuitem label="SubMenuItem D-3" type="radio" 

                              groupName="one"/>

                </menuitem>

            </root>

        </fx:XML>

  &nb! sp; </fx:Declarations>

    

    <fx:Script>

        <![CDATA[

            

            import mx.controls.Menu;

            

            // Create and display the Menu control.

            private function createAndShow():void 

            {

                var myMenu:Menu = Menu.createMenu(null, myMenuData, false);

                myMenu.labelField="@label";

                myMenu.show(10, 10);

     !        }

     !  &n bsp; ]]>

    </fx:Script>

    <s:VGroup>

        <s:Button id="myButton" 

                  label="Open Menu" 

                  click="createAndShow();"/>

    </s:VGroup>

</s:Application>





To: flexcoders@yahoogroups.com

From: aha...@adobe.com

Date: Wed, 7 Mar 2012 22:55:23 -0800

Subject: Re: [flexcoders] Flex Menu.createMenu on mouseDown issue



 

 

 

   What happens?





On 3/7/12 6:06 PM, "method_air" <loudj...@hotmail.com> wrote:





 

 

 

   



Attempting to create a flex Menu on 'mouseDown' is failing (but works using the 
'click' event):



private function createAndShow():void 

{

var myMenu:Menu = Menu.createMenu(null, myMenuData, false);

    myMenu.show(10, 10);

}

]]>

</mx:Script>







<!-- Define a Button control to open the menu -->

<s:Button mouseDown="createAndShow();"/>



Is there a workaround?



Thanks,



Philip



 

   







-- 

Alex Harui

Flex SDK Team

Adobe Systems, Inc.

http://blogs.adobe.com/aharui







    
     

    
    






                                          

Reply via email to