This site seems to be pretty good:
http://www.brucephillips.name/blog/index.cfm/2007/1/8/Example-Of-
Using-Modules-In-Flex-201

But I am still missing something. It seems that my modules are loaded 
even if I don't explisitly load them.

Here is my test app:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
   xmlns:mx="http://www.adobe.com/2006/mxml"; 
   initialize="onInit(event)"
   creationComplete="onCreationComplete(event)"
   layout="absolute">
   <mx:Script>
      <![CDATA[
private var debug:Boolean = false;
private var modLoader:ModuleLoader;
private var modName:String = "string_en.swf";

import mx.events.ModuleEvent;
import mx.modules.IModuleInfo
import mx.modules.ModuleLoader;
import mx.modules.ModuleManager;

private function onInit(event:Event) : void
{
   this.debug = (this.url.indexOf("-debug.swf") > -1 ? true : false);
/*
   var info:IModuleInfo = ModuleManager.getModule( getModuleName( 
modName ) );
   
   info.load();
*/
}

private function onCreationComplete(event:Event) : void
{
   /*
   modLoader = new ModuleLoader();
   this.addChild(modLoader);
   createModule( modLoader, modName );
   */
}

private function getModuleName( modName:String ):String
{
   var s:String = modName;
   if ( this.debug  && ( s.indexOf( "-debug.swf" ) == -1 ) )
   {
      s = s.replace(".swf", "-debug.swf");
   }
   
   return s;
}

public function createModule(m:ModuleLoader, s:String):void
{
   if (!m.url)
   {
      m.url = getModuleName( s );
   }
   
   m.loadModule();
}

public function removeModule(m:ModuleLoader):void
{
   m.unloadModule();
}

private function Test_OnClick(event:Event) : void
{
   textArea.text = string_en.Cancel;
   //var obj:string_en = (modLoader.child as string_en);
}

      ]]>
   </mx:Script>
   <mx:Text text="Text" right="10" left="10" top="40" bottom="207" 
id="textArea"/>
   <mx:Button x="10" y="10" label="Test" click="Test_OnClick(event)"/>
</mx:Application>




and here is my test module:

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml";>
   <mx:Script>
      <![CDATA[
public static const Ok:String = "OK";           // OK button
public static const Cancel:String = "Cancel";   // Cancel button
public static const Submit:String = "Submit";   // Submit button
         
public function Item( name:String ) : String
{
   return "";
}
      ]]>
   </mx:Script>
</mx:Module>




If you notice I have commented out the code that loads the module. 
Yet even then then module loads and I can get at the strings. 


I just want to make sure that my modules only load when asked for.

Mike



--- In flexcoders@yahoogroups.com, "tvikatos" <[EMAIL PROTECTED]> wrote:
>
> No sure if it covers everything you need but have alook at my post:
> 
http://blog.startup.gr/blog/Technology/Flex/_archives/2007/1/19/266488
0.html
> 
> leave a comment if you have any specific question.
> Harry
>


Reply via email to