Yeah I see what you mean. It seems like you should be able to pull the currently selected item like from a drop down list. It looks like you would have to make a variable to capture the data from the return event. So it could be something like

private var selectedItem : Object = new Object();

private function actionSelect(event:MenuEvent):void  {
    selectedItem.data = [EMAIL PROTECTED];
    selectedItem.label = [EMAIL PROTECTED];
}

private function okClicked():void {  // Event handler for the OK button.
   Alert.show("fname= "+fname.text +
       "\nday= "+day.selectedValue+" "+day.selection.label +
       "\naction= " + *selectedItem.data* + " " + *selectedItem.label*);
   PopUpManager.removePopUp(this);
}

I haven't actually tried out the code but that seems to work conceptually. It seems like it would be useful to be able to pull the selected data directly but the docs don't mention that as an option. It only talks about the itemClick and click events.

Hope that helps,

Michael


fredsells wrote:

I've got a data entry "dialog" with a PopUpButton control. Although I can get the data value from the event, I really don't want to handle the event but rather wait for the user to hit the OK button in the dialog, then get the selected data. I have searched the docs and googled it to death with no success. I'm a flex newbie, so this is probably something really obvious, but I can't find it. Code snippets are below...

<mx:Script> <![CDATA[ private function okClicked():void { // Event handler for the OK button.
                Alert.show("fname= "+fname.text +
"\nday= "+day.selectedValue+" "+day.selection.label + "\naction= "+punchtype.selected+" "+punchtype.label); //how do I get data
                PopUpManager.removePopUp(this);
       }
private function actionSelect(event:MenuEvent):void { Alert.show("data="[EMAIL PROTECTED]" "[EMAIL PROTECTED]) ; //this works
    }
]]> </mx:Script>

    <mx:XMLList id="treeDP2">
        <node label="Punch In"  data="1" />
        <node label="Punch Out"  data="2" />
        <node label="Left Building"  data="3" />
        <node label="Left Planet"  data="4" />
    </mx:XMLList>
......
            <mx:FormItem label="Action">
<mx:PopUpMenuButton id="punchtype" dataProvider="{treeDP2}" labelField="@label" itemClick="actionSelect(event);"/> </mx:FormItem>


Reply via email to