The module will share the button w the main app

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dennis van Nooij
Sent: Thursday, October 25, 2007 2:34 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] ModuleManager.getAssociatedFactory returning wrong
result ?

 

Hi,

I'm trying to split up my application into modules but ran into this
weird behaviour. According to the docs getAssociatedFactory should
return "See if the referenced object is associated with (or, in the
managed ApplicationDomain of) a known IFlexModuleFactory implementation"

The thing is when I startup my app without modules it returns null (as
it should) but when I load a module it returns the same factory for
objects in the module as well as in the shell .. ?

Here's the code:

Shell:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute" creationComplete="loadModule()">
<mx:Script>
<![CDATA[
import mx.modules.ModuleLoader;
import mx.modules.ModuleManager;

private function loadModule () : void {

var factory = ModuleManager.getAssociatedFactory(shellButton);
trace("factory " + factory);
if (factory != null)
trace("factory name " + factory.name);
var module_ldr:ModuleLoader = new ModuleLoader();
module_ldr.url = "ButtonModule.swf";
module_ldr.loadModule();
this.addChild(module_ldr);
}

private function traceFactory () : void {

var factory = ModuleManager.getAssociatedFactory(shellButton);
trace("factory " + factory);
if (factory != null)
trace("factory name " + factory.name);
} 
]]>
</mx:Script> 
<mx:Button id="shellButton" x="166" y="41" label="Shell Button"
click="traceFactory()"/>
</mx:Application>

Module:

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

private function traceFactory () : void {

var factory = ModuleManager.getAssociatedFactory(button);
trace("factory " + factory);
if (factory != null)
trace("factory name " + factory.name);
} 
]]>
</mx:Script> 
<mx:Button id="button" x="166" y="141" label="Module Button"
click="traceFactory()"/> 
</mx:Module>

With this output:

[SWF]
Users:dennisvannooij:Documents:workspace:ModuleTest:bin:ModuleTest.swf
- 522,921 bytes after decompression
factory null
[SWF]
Users:dennisvannooij:Documents:workspace:ModuleTest:bin:ButtonModule.swf
- 518,830 bytes after decompression
factory [object _ButtonModule_mx_core_FlexModuleFactory]
factory name instance16
factory [object _ButtonModule_mx_core_FlexModuleFactory]
factory name instance16

Last two traces are from clicking first the shell button, then the
module button..

am I missing something here ?

Dennis

 

Reply via email to