3 Replies Latest reply on Jun 14, 2011 12:23 PM by Darrell Loverin

    Issue regarding module loading

    Sathavaram Reddy

      I have two files

      1.Mainapplication file (mainapplication.mxml)

      2.Module File(module.mxml)

       

      In my main application if i define a varibale of type module..then its throwing a weird error..

       

      Error #1009: Cannot access a property or method of a null object reference.
          at mx.styles::StyleProtoChain$/initProtoChainForUIComponentStyleName()[E:\dev\4.x\frameworks \projects\framework\src\mx\styles\StyleProtoChain.as:356]

       

      Sample code

      Main application:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                             xmlns:s="library://ns.adobe.com/flex/spark"
                             xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:MainFiles="MainFiles.*"
                            >
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import ModuleFiles.modulecomp1;
                 
                  import mx.events.ModuleEvent;
                  import mx.modules.IModuleInfo;
                  import mx.modules.ModuleManager;
                  public var mod:IModuleInfo;
                  private var Mod1:ModuleFile;

       

                 
                  private function load():void{
                  mod = ModuleManager.getModule("ModuleFile.swf");
                  mod.addEventListener("ready", navigateToModuleViews);
                  mod.load(); 
                  }
                 
                  private function navigateToModuleViews(event:ModuleEvent):void{
                      //Mod1 = mod.factory.create() as ModuleFile;
                      //Mod1.mod1ViewStack.selectedIndex = 1;
                  }
                  private function unload():void{
                      moduleTest.unloadModule();
                  }
                 
              ]]>
          </fx:Script>
          <s:VGroup width="100%" height="100%">
              <mx:ModuleLoader id="moduleTest" url="ModuleFile.swf"/>
              <mx:Button label="Unload" click="unload()"/>
          </s:VGroup>
      </s:WindowedApplication>

       

       

      Module File

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
                 xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="400" height="300"
                 xmlns:ModuleFiles="ModuleFiles.*">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  private function change():void{
                      mod1ViewStack.selectedIndex = 1;
                  }
              ]]>
          </fx:Script>
          <s:VGroup width="100%" height="100%">
              <mx:ViewStack  id="mod1ViewStack" width="100%" height="100%">
              <s:NavigatorContent width="100%" height="100%">
                  <ModuleFiles:modulecomp1/>
              </s:NavigatorContent>
              <s:NavigatorContent width="100%" height="100%">
                  <ModuleFiles:Modulecomp2/>
              </s:NavigatorContent>
          </mx:ViewStack>
              <mx:Button label="Change" click="change();"/>
          </s:VGroup>
      </mx:Module>

       

      That Mod1 is creating the problem...