Alex thanks for your reply, basically my application has total 10 screens and  
6 out 10 screens will be used in other flex applcations , so what i have 
decided is to make all 10 screens as module and 10 presenter classes for each 
module.
(Do you think it is a good approach?). Now as you said use Interface, their is 
no problem in using interface, but my presenter class needs to know the actual 
Module name so that i can access the individual components of modules in 
presenter class.  one more thing my Modules are passive view . can you help me 
how to solve this problem. becuse my presenter classes are totaly dependente 
view(Module)..
  ----- Original Message ----- 
  From: Alex Harui 
  To: flexcoders@yahoogroups.com 
  Sent: Sunday, June 22, 2008 3:12 AM
  Subject: RE: [flexcoders] Problem While Downcasting Flex Modules



  Your example doesn't make sense because if you have the types FlexModule1 and 
FlexModule2 in the main app, those classes are linked into the main app and 
you've defeated the whole point of modules.  You should be using interfaces 
instead.



  However, by default, a module will be compiled without a package (actually 
"package {"} so it won't be of type modules.FlexModule1, it will just be 
FlexModule1




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

  From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
[EMAIL PROTECTED]
  Sent: Saturday, June 21, 2008 2:54 AM
  To: flexcoders@yahoogroups.com
  Subject: [flexcoders] Problem While Downcasting Flex Modules



  HI everyone,
  I am facing a problem while down casting the flex module.

  I have created two flex modules called FlexModule1.mxml and FlexModule2.mxml.

  These both modules contain the same code.

  I have placed FlexModule1.mxml under modules folder(modules/FlexModule1.mxml) 
and FlexModule2.mxlm @ application root.
  Here is code for FlexModul1.mxlml (and FlexModule2.mxml as both modules have 
identical code)

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

  <mx:Script>
  <![CDATA[ 
  public function Foo( pstr:String ):String
  {
  trace( "In Method Foo" );
  return "Foo" + pstr ;
  }
  ]]>
  </mx:Script> 

  <mx:Panel width="100%" height="100%">
  <mx:Label id="MY_LABEL" text="I AM MODULE-1" fontSize="20" color="green"/>
  </mx:Panel>

  </mx:Module>

  And here is Main class code.

  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical" 
creationComplete="{loadModule()}">

  <mx:Script>
  <![CDATA[
  import mx.modules.ModuleManager;
  import mx.modules.IModuleInfo;
  import modules.FlexModule1;
  import mx.events.FlexEvent;
  import mx.events.ModuleEvent;
  import mx.modules.ModuleLoader;

  public var moduleLoader:ModuleLoader;
  public var moduleInfo:IModuleInfo;

  public function loadModule( ):void
  {
  moduleLoader = new ModuleLoader();
  moduleLoader.addEventListener( ModuleEvent.READY , moduleReadyEventHandler );
  //moduleLoader.url = "FlexModule2.swf"; //This is fine module loaded 
  moduleLoader.url = "modules\\FlexModule1.swf"; //this fine too 
  moduleLoader.loadModule();
  }


  public function moduleReadyEventHandler( evt:ModuleEvent ):void
  {
  trace( "Module Ready Event Handler" );
  this.addChild( moduleLoader ); 
  //(moduleLoader.child as FlexModule2).Foo( '' ) ; // this if fine method 
Foo() called
  (moduleLoader.child as FlexModule1).Foo( '' ) ; // Null pointer Exception
  }
  ]]>

  </mx:Script>

  </mx:Application>

  Both modules are loading without any problem but the error occurs when I try 
to downcast FlexModule1.mxml. There is no down casting problem with 
FLexModule2.mxlm.
  I think the problem is with different folder i have used for FlexModule1.mxml 
, may b i am wrong. 
  Please let me know where is the problem.



   

Reply via email to