Search code examples
apache-royale

create or add section content at runtime


I want to add / create section content at runtime. I see example from tour de jewel mainContent.mxml but seems it is all section content is loaded when application start.

I want only load the section content when it's needed, not loading at all when application start.

So, when there is an update from individual section content, we don't need to refresh the browser.

<j:ApplicationMainContent localId="main" hasTopAppBar="true" hasFooterBar="true" selectedContent = "welcome_panel">
    <local:WelcomeSection name="welcome_panel"/>
    <local:AlertPlayGround name="alert_panel"/>
    <local:ButtonPlayGround name="button_panel"/>
    <local:ImagePlayGround name="image_panel"/>
    <local:NumericStepperPlayGround name="numericstepper_panel"/>
    <local:DateComponentsPlayGround name="datecomponents_panel"/>
    <local:ComboBoxPlayGround name="combobox_panel"/>
    <local:CheckBoxPlayGround name="checkbox_panel"/>
    <local:MiscelaneaPlayGound name="miscelanea_panel"/>
    <local:HeadingsAndText name="text_panel"/>
    <local:LabelPlayGround name="label_panel"/>
    <local:ListPlayGround name="list_panel"/>
    <local:RadioButtonPlayGround name="radiobutton_panel"/>
    <local:SliderPlayGround name="slider_panel"/>
    <local:TextInputPlayGround name="textinput_panel"/>
    <local:GridPlayGround name="grid_panel"/>
    <local:CardPlayGround name="card_panel"/>
    <local:TablePlayGround name="tables_panel"/>
    <local:FormsValidationPlayGround name="form_validation_panel"/>
    <local:DropDownListPlayGround name="dropdownlist_panel"/>
    <local:SnackbarPlayGround name="snackbar_panel"/>
    <local:TabBarPlayGround name="tabbar_panel"/>
    <local:ViewStatesPlayGround name="viewstates_panel"/>
    <local:LayoutsPlayGround name="layouts_panel"/>
    <local:WizardPlayGround name="wizards_panel"/>
    <local:PopUpPlayGround name="popup_panel"/>
</j:ApplicationMainContent>

Please help


Solution

  • Imagine that you don't have declared the button panel in mxml. You can create it with the following code:

    // This creates the ButtonPlayGround view
    var bp:ButtonPlayGround = new ButtonPlayGround();
    // then we need to assign the name
    bp.name = "button_panel";
    // finally you need to add to the ApplicationMainContent container
    main.addElement(bp);
    

    Now when you try to show that view, you'll get it since.