Change the line from info.load(ApplicationDomain.currentDomain);
to info.load(); On Thu, Apr 28, 2011 at 7:59 PM, Deepan prabu <deepan.pr...@gmail.com>wrote: > Hi > I have sceanerio where loading module in view stack and maintain its > state. > I facing problem durning selectedChildren in view stack. Please find > snippet of code > > *Shell.mxml* > * > * > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="horizontal" > width="100%" height="100%" minWidth="1000" minHeight="600"> > <mx:Script> > <![CDATA[ > import com.module.TestClass; > private var loadedApps : Dictionary = new Dictionary(); > public function showTab( url : String ) : void { > var tabView : ModuleContainer = loadedApps[url] as ModuleContainer; > > if ( tabView != null ) { > appsViewStack.selectedChild = tabView; > } else { > var mcView : ModuleContainer = new ModuleContainer(url); > var mcDO : DisplayObject = mcView as DisplayObject; > appsViewStack.addChild(mcDO); > appsViewStack.selectedChild = mcView; > loadedApps[url] = mcView; > } > } > ]]> > </mx:Script> > > <mx:Canvas id="applicationBody" > x="0" y="0" > width="100%" height="100%"> > <mx:HBox width="100%" height="30" x="3" y="3"> > <mx:Button label="Cricket" click="showTab('cricket.swf')"/> > <mx:Button label="Football" click="showTab('football.swf')"/> > <mx:Button label="Hockey" click="showTab('hockey.swf')"/> > <mx:Button label="Tennis" click="showTab('tennis.swf')"/> > </mx:HBox> > <mx:ViewStack id="appsViewStack" > width="100%" > height="100%" > backgroundColor="#DBDBDB" > y="31" x="0"> > </mx:ViewStack> > </mx:Canvas> > </mx:Application> > > *ModuleContainer.as* > * > * > package test { > import flash.events.Event; > import flash.system.ApplicationDomain; > import mx.containers.Canvas; > import mx.controls.Alert; > import mx.controls.Label; > import mx.core.UIComponent; > import mx.events.ModuleEvent; > import mx.managers.CursorManager; > import mx.modules.IModuleInfo; > import mx.modules.ModuleManager; > public class ModuleContainer extends Canvas { > > private var info:IModuleInfo = null; > private var module:UIComponent = null; > private var moduleUrl : String = null; > public function ModuleContainer(url : String) { > super(); > this.moduleUrl = url; > this.loadModule(); > } > public function loadModule( ) : void { > info = ModuleManager.getModule(this.moduleUrl); > if (info != null) { > info.addEventListener(ModuleEvent.READY, onReady); > info.addEventListener(ModuleEvent.ERROR, onError); > info.load(ApplicationDomain.currentDomain); > } > } > public function onReady( event:ModuleEvent ) : void { > info.removeEventListener(ModuleEvent.READY, onReady); > info.removeEventListener(ModuleEvent.ERROR, onError); > module = info.factory.create() as UIComponent; > if ( module != null ) { > /* var t:Label = new Label(); > t.text = moduleUrl; > this.addChild(t); */ *Uncomment this you can see label value change in > stage durning module change* > module.x = 0; > module.y = 50; > module.percentWidth = 100; > module.percentHeight = 100; > this.addChild(module); > } > } > public function onError(event:Event) : void { > // cleanup and display an error alert > info.removeEventListener(ModuleEvent.READY, onReady); > info.removeEventListener(ModuleEvent.ERROR, onError); > info = null; > Alert.show(event.toString(), "Error Loading Module"); > CursorManager.removeBusyCursor(); > } > } > } > > > Thanks > Deepan > > -- > You received this message because you are subscribed to the Google Groups > "Flex India Community" group. > To post to this group, send email to flex_india@googlegroups.com. > To unsubscribe from this group, send email to > flex_india+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/flex_india?hl=en. > -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_india@googlegroups.com. To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.