You need to have a strong reference to the IModuleInfo otherwise it can get 
GC'd.

I discussed this problem on my blog.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Mayur
Sent: Sunday, November 22, 2009 11:06 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Issue of RSL for a Module



I have an issue of RSL with Module.

code snippet
-----------------------------------------

private var moduleInfo:IModuleInfo;

public var moduleURL : String = "MyPersonalHomePage.swf";

moduleInfo = ModuleManager.getModule( moduleURL );


moduleInfo.addEventListener( ModuleEvent.READY, onModuleReady );


moduleInfo.addEventListener( ModuleEvent.ERROR, onModuleError );

moduleInfo.load();

protected function onModuleReady( moduleEvent:ModuleEvent ):void
{
var moduleInfo:IModuleInfo = moduleEvent.module;

var objModuleInfo : Object = moduleInfo.factory.info();

//var dictionaryOfModule : Dictionary = moduleInfo.factory.preloadedRSLs;

// upto above point things are fine ( in debug I can see that module is 
loaded="true" ready="true" )
// - as soon as I run the below line ( create() on factory ) the module 
instance returned ' null '
// can some one explain me what's going wrong internally

var moduleObject: Object = moduleInfo.factory.create();


if(moduleObject != null)
{
if(moduleObject is IDummyInterface)
{
var dummyContent: IDummyInterface = moduleObject as IDummyInterface;
dummyContent.setParameter("xyzstring");
dummyContent.setDP(testXML);
}
else
{
Alert.show(" +-+-+-+-+-+ module is not available +-+-+-+-+-+");
}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module : MyPersonalHomePage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml";
implements="IDummyInterface"
focusEnabled="true" >

// some open sournce flex libraries are used here

// e.g. Papervision, Tweener, Degrafa etc.

</mx:Module>

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

Mayur

Reply via email to