All problems (so far) concerning modules have faded for me :) Big thnx to mr. Gonzalez for pointing me at some undocumented classes. For reference i will tell you what i tried and which problems i encountered:
 
The first thing i tried was creating libraries (swc files). I would then extract the swf from the library and load it dynamically into my base flex application, instantiated the component and all was well. This worked fine with Text components but failed when i used a TextArea. I got a strange error regarding some resource bundle. This was solved by forcing the " ${flexlib}/locale/en_US/framework_rb.swc" file into my main application. The next problem that came up was some runtime error about a missing class definition. This was caused by missing default styles, which are automatically handled by mxmlc, but not by compc. This could be solved by getting the default styles definitions from a compiled application's generated AS files and put them into my component. This turned out to be very messy and i gave up using a library as a module.
 
The second thing i tried was using the mx.core.Application class as a base for each module. This worked really well with the styles and all that kind of shizzle. There was however one little problem: the loaded application did not handle resizes well and did not participate very well in the whole layout mechanism. I have tried detecting changes in its childen and passing it to the parent loader, setting the parent loader as parent, etc. All very messy...
 
The last and working solution (for me) is using a Canvas as base for my modules. In the module class definition i have the following metadata tag present: [Frame(factoryClass="mx.core.FlexApplicationBootstrap ")], this tag makes sure i can compile the mxml file (which extends the module / Canvas) with the mxmlc compiler. Notice that i did not use the [Frame(factoryClass="mx.core.FlexModuleFactory")] tag. The reason is as with the first set of problems: styles. Components are messed up when using this type of factory (for example a datagrid has a black rollover color).
 
In short the (simplified) code to get a module somewhere on the stage:
 
//event handler for Event.INIT on the loader
private function _moduleInitialized(e:Event):void
{
   var loaderInfo:LoaderInfo = e.target as LoaderInfo;
   var applicationBootstrap:FlexApplicationBootstrap = loaderInfo.content as FlexApplicationBootstrap;
   //we can now delete the reference to the loader because we no longer need the loader.
   delete _loaders[loaderInfo.loader];
   applicationBootstrap.addEventListener("ready", _moduleReady);
};
 
private function _moduleReady(e:Event):void
{
   var moduleBootstrap:FlexApplicationBootstrap = e.target as FlexApplicationBootstrap;
   var module:IModule = moduleBootstrap.create() as IModule;
  
   addChild(module as DisplayObject);
};
 
Hope this is of any use for some1 in the future.
 
 
Greetz Erik
 
__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to