try the following program in flex 2(they come from flex help 
documentation,):

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>

    <mx:Script>
        <![CDATA[

            import mx.controls.*;
            import mx.events.*;

            private var myMenu:Menu;

            // Initialize the Menu control, and specify it as the pop 
up object
            // of the PopUpButton control. 
            private function initMenu():void {
                myMenu = new Menu();
                var dp:Object = [{label: "New Folder"}, {label: "Sent 
Items"},                    {label: "Inbox"}];        
                myMenu.dataProvider = dp;
                myMenu.addEventListener("itemClick", changeHandler);
                popB.popUp = myMenu;
            }

            // Define the event listener for the Menu control's 
change event. 
            private function changeHandler(event:MenuEvent):void {
                var label:String = event.label;        
                popTypeB.text=String("Moved to " + label);
                popB.label = "Put in: " + label;
                popB.close();
                Alert.show('y');
            }
        ]]>
    </mx:Script>

    <mx:VBox>
        <mx:Label text="Main button mimics the last selected 
menuItem." />
        <mx:PopUpButton id="popB" label="Edit" 
width="135"             creationComplete="initMenu();"/>
        
        <mx:Spacer height="50"/>
        <mx:TextInput id="popTypeB"/>

    </mx:VBox>
</mx:Application>

the problem is in the changeHandler menuEvent handler function,after 
items in popupButton was clicked,changeHandler event function always 
execute twice.so everytime i click just 1 time,i got 2 Alert of 'y'!!
PS:there were some time that it did act normal,eg:u click the first 
item of popupButton,but after that the "twice" effect comes again...
tks for ur time and any replyment will be greatly appreciated.

Reply via email to