Hi,

I run into problem that the module is not loading when using
ModuleManager...


[code Main File]

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical" >
<mx:Script>
        <![CDATA[
                import mx.core.UIComponent;
                import mx.modules.Module;
                import mx.events.ModuleEvent;
                import mx.modules.ModuleManager;
                import mx.modules.IModuleInfo;

                [Bindable]
                private var labelText:String;

                private var sampleModule:UIComponent;

                private var info:IModuleInfo;
                private var info2:IModuleInfo;
                /* private var myMod:MyModule;

                private function loadLabel():void
                {

                        myMod = module.child as MyModule;
                        labelText = myMod.getString();

                } */

                private function handleLoad(e:MouseEvent):void
                {
                        info = ModuleManager.getModule("MyModule.swf");
                        info.addEventListener(ModuleEvent.READY, 
handleModuleLoad)
                        info.load(ApplicationDomain.currentDomain);
                }

                private function handleModuleLoad(e:ModuleEvent):void
                {
                        trace("inside module handler");
                        info2 = e.module;
                        if(sampleModule == null){
                                sampleModule = info.factory.create() as 
UIComponent;
                                if(sampleModule !=null){
                                        sampleModule.x =0
                                        sampleModule.y =0
                                        sampleModule.percentHeight = 100;
                                        sampleModule.percentWidth = 100;

                                        canvas.addChild(sampleModule);
                                }
                        }

                }


                private function handleUnload(e:MouseEvent):void
                {


                }
        ]]>
</mx:Script>
        <mx:Label text="{labelText}"/>
        <mx:Button label="LoadModule" click="handleLoad(event)"/>
        <mx:Button label="UnLoadModule" click="handleUnload(event)"/>
        <mx:Canvas id="canvas" height="100%" width="100%"/>
<!--    <mx:ModuleLoader id="module" url="MyModule.swf"
ready="loadLabel();"/>-->
</mx:Application>

[/code]

--------------------------------------------------------------------

[code Module]

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
width="400" height="300">
<mx:Script>
        <![CDATA[

                public function getString():String
                {
                        return "Data from Module";
                }
        ]]>
</mx:Script>
        <mx:Button label="click"/>
</mx:Module>

[/code]

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to