Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:01:57+00:00 2026-06-12T08:01:57+00:00

I have a Flex application and need to generate a menu programatically, it will

  • 0

I have a Flex application and need to generate a menu programatically, it will be quite complex and dynamic. What is the best technique for doing this?

UPDATE : I’ve tested out the code below using objects for the menu items and children properties as RIAstar suggested. This is working except I don’t see the “Input” menu, it seems to be bypassed. What I see is:

Screenshot

I was expecting “Add->Input->Device{0..8}”.

Thanks for any ideas, Fred.

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

<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.controls.Menu;
        protected function button1_clickHandler(event:MouseEvent):void
        {
            var toplevelMenu:Object = new Object();
            toplevelMenu.label = "Top Level";
            var addMenu:Object = new Object();
            addMenu.label = "Add";
            toplevelMenu.children = addMenu;

            var inputMenu:Object = new Object();
            inputMenu.label = "Input";

            var inputDevicesMenu:ArrayCollection = new ArrayCollection();
            for (var i:int = 0;i < 10;i++) {
                if ((i % 2) == 0) {
                    var inputDeviceMenu:Object = new Object();
                    inputDeviceMenu.label = "Device " + i;
                    inputDevicesMenu.addItem(inputDeviceMenu);
                }
            }
            if (inputDevicesMenu.length > 0) {
                inputMenu.children = inputDevicesMenu;
            }
            addMenu.children = [inputMenu];

            var menu:Menu = Menu.createMenu(this, toplevelMenu, false);
            menu.show(event.stageX, event.stageY);
        }
    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="56" y="28" label="Show Menu" click="button1_clickHandler(event)"/>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:01:58+00:00Added an answer on June 12, 2026 at 8:01 am

    As per RIAstar suggestion and you code, i have made some modification in button1_clickHandler function: –

    Updated code in function button1_clickHandler: –

    protected function button1_clickHandler(event:MouseEvent):void
                {
                    var addMenu:Object = new Object();
                    addMenu.label = "Add";
    
                    var inputMenu:Object = new Object();
                    inputMenu.label = "Input";
    
                    var outputMenu:Object = new Object();
                    outputMenu.label = "Output";
    
                    var inputOutputDevicesMenu:ArrayCollection = new ArrayCollection();
                    inputOutputDevicesMenu.addItem(outputMenu);
                    inputOutputDevicesMenu.addItem(inputMenu);
    
                    addMenu.children = inputOutputDevicesMenu;
    
                    var inputDevicesMenu:ArrayCollection = new ArrayCollection();
                    for (var i:int = 0;i < 10;i++) {
                        if ((i % 2) == 0) {
                            var inputDeviceMenu:Object = new Object();
                            inputDeviceMenu.label = "Device " + i;
                            inputDevicesMenu.addItem(inputDeviceMenu);
                        }
                    }
                    if (inputDevicesMenu.length > 0) {
                        inputMenu.children = inputDevicesMenu;
                    }
    
                    var menu:Menu = Menu.createMenu(this, addMenu, true);
                    menu.show(event.stageX, event.stageY);
                }
    

    Hope this may help to get some idea……

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flex client application. I need a clean up function to run
I have a portlet. Inside of this portlet I have Flex application that displays
I have a flex application and need to show the real time data into
I have a flex application about 2M need to send to browser, so I
I have a Flex Application, and I need to track site catalyst data with
I have a Flex application (SDK 4.5.1) which runs on iPad... I need to
Will OpenAM work if cookies are disabled? I have a Flex application and on
I'm building a Flex application that will need run under two different deployment scenarios:
I have a Flex application which is served via a JSP page. In this
I have a flex application that needs the ability to generate and execute JavaScript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.