after experimenting, it turned out to be remarkly easy:

n = apps.selectedChild as ModLoaderNC;
                n.addElement(modLoader.factory.create() as IVisualElement);

On 8/18/2010 9:19 AM, Wally Kolcz wrote:

I am creating a UI where the user is presented with tabs using a <s:TabBar> and a <mx:ViewStack> as the application loads, I add a empty NavigatorContent with the names of the apps by looping through a dataset. Each tab represents a module that is to be loaded when the user clicks it. The problem I am running into is how to put the module into the NavigatorContent area correctly. When I tried to add it to the ViewStack based on the index that is selected, it adds another tab to the list. How can I add it to the correct NavigatorContent? Here is the code that generates the original list (there is a static 'first tab content') so the user is not bored :)

private function buildMenu():void {
                var fn:ModLoaderNC = new ModLoaderNC();
                    fn.label = "Welcome";
                    fn.path = "";
                    var ws:AdminWelcome = new AdminWelcome();
                    fn.addElement(ws);
                    apps.addChild(fn);
               // Loops though modules list from database
                for (var i:int = 0; i < modules.length; i++){
                    var n:ModLoaderNC = new ModLoaderNC();
                    n.label = modules.getItemAt(i).modName;
                    n.path = modules.getItemAt(i).path;
                    apps.addChild(n);
                }
                var st:ModLoaderNC = new ModLoaderNC();
                st.label = "Need Help?";
                st.path = "com/wallykolcz/views/support/Support.swf";
                apps.addChild(st);
            }

Here is the final code that takes the loaded module and trys to add it to the viewstack ('apps' is the id of the ViewStack:

private function modLoadedHandler(e:ModuleEvent):void {
apps.addElementAt(modLoader.factory.create() as IVisualElement, apps.selectedIndex);

            }


Reply via email to