Apache – how to load Module to control like panel , vbox etc +flex

apache-flexflex3

I'm new to this flex. Can anybody solve my problem? This is my query: I have ahome page divided into 3 parts like top, left, middle positons. In the middle postion -panel and combobox are there. I want to load my module to the middle positon like to panel. I have combobox, when I selected any item based on that I'm loading a module to that panel using Custom moduleloader control. Up to here it's working fine. My probelm: I select one option from combobox, it shows the one module(sam1). When I click(sam1), it should open anothermodule(sam2) in same location (instead of sam1-sam2). So can you tell me your ideas on how to resolve it?

Best Answer

It sounds like what you need is to put all the modules into a ViewStack. Then you have a choice:

  • You can simply bind to an index in the combobox (or an index specified by the combobox data like I have in the example below).
  • You can pickup the change event of the ComboBox and manually change the selectedChild of the ViewStack.
  • You can

Something like:

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

    <mx:Script>
        <![CDATA[
            [Bindable]
            public var modules:Array = 
                [ {label:"Module A", moduleIndex:0}, 
                  {label:"Module B", moduleIndex:1}, 
                  {label:"Mobule C", moduleIndex:2} ]);
        ]]>
    </mx:Script>

    <mx:ComboBox dataProvider="{modules}" id="modulesCombobox" />

    <mx:ViewStack id="modulesViewStack" creationPolicy="auto" 
            selectedIndex="{modulesCombobox.selectedItem.moduleIndex}">

        <mx:ModuleLoader id="moduleA" url="{'views/ModuleA.swf}" /> 
        <mx:ModuleLoader id="moduleB" url="{'views/ModuleB.swf}" /> 
        <mx:ModuleLoader id="moduleC" url="{'views/ModuleC.swf}" /> 
    </mx:ViewStack>
</mx:Application>
Related Topic