Reputation: 9
I have an swiz application that loads swiz.modules.Module/ The module uses Swiz also. The application works correctly when i run it from FlashBuilder. The release vertion works incorrectly inside browser. Th module's presentation model does no injects into the view (module). Apache Flex 4.13 Flash player 11.5 Any browser
Here is my code
Application
<s:Application 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:config="swiz.conf.*"
xmlns:swiz="http://swiz.swizframework.org"
width="955"
height="600"
addedToStage="application1_addedToStageHandler(event)">
<fx:Script>
<![CDATA[
// to enable managers inside modules
import mx.managers.CursorManager;
import mx.managers.DragManager;
import mx.managers.PopUpManager;
import mx.managers.ToolTipManager;
import mx.core.EmbeddedFontRegistry;
private var popUpManager:PopUpManager;
private var dragManager:DragManager;
private var tooltipManager:ToolTipManager;
private var _cursorManager:CursorManager;
private var embeddedFontRegistry:EmbeddedFontRegistry;
import swiz.pm.AppPM;
[Inject]
public var appPM:AppPM;
protected function application1_addedToStageHandler(event:Event):void
{
appPM.viewAddedToStage();
}
]]>
</fx:Script>
<fx:Declarations>
<swiz:Swiz id="mySwiz" >
<swiz:beanProviders>
<config:MainApplicationBeans/>
</swiz:beanProviders>
<swiz:config>
<swiz:SwizConfig viewPackages="swiz.views.*"
eventPackages="swiz.events.*"/>
</swiz:config>
</swiz:Swiz>
</fx:Declarations>
<mx:UIComponent id="modulesContainer"/>
AppController
package swiz.controllers
{
import mx.events.ModuleEvent;
import spark.modules.ModuleLoader;
import org.swizframework.controller.AbstractController;
import swiz.models.AppModel;
import swiz.pm.AppPM;
public class AppController extends AbstractController
{
[Inject]
public var appPM:AppPM;
[Inject]
public var appModel:AppModel;
protected var modulesLoader:ModuleLoader;
[PostConstruct]
public function initHandler():void
{
modulesLoader = new ModuleLoader();
}
[EventHandler(event="AppPMEvent.VIEW_ADDED")]
public function viewAddedHandler():void
{
appPM.addModuleLoader(modulesLoader);
//load first module
modulesLoader.addEventListener(ModuleEvent.READY,moduleReadyHandler);
modulesLoader.url = appModel.firstModulePath;
}
protected function moduleReadyHandler(event:ModuleEvent):void
{
trace("module loaded but not inited yet");
}
}
}
AppSwizConfig
<?xml version="1.0" encoding="utf-8"?>
<swiz:BeanProvider xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:swiz="http://swiz.swizframework.org"
xmlns:controllers="swiz.controllers.*"
xmlns:pm="swiz.pm.*"
xmlns:models="swiz.models.*" >
<!-- CONTROLLERS -->
<controllers:AppController id="appController"/>
<!-- MODELS -->
<models:AppModel id="aappModel"/>
<!-- PM -->
<pm:AppPM id="appPM"/>
appPM
package swiz.pm
{
import flash.events.IEventDispatcher;
import spark.modules.ModuleLoader;
import swiz.events.AppPMEvent;
// application view presentation module
public class AppPM
{
[Dispatcher]
public var dispatcher:IEventDispatcher;
protected var view:SwizFlexSparkModulesTest;
[ViewAdded]
public function viewAddedHandler(_view:SwizFlexSparkModulesTest):void
{
view = _view;
}
public function viewAddedToStage():void
{
var event:AppPMEvent = new AppPMEvent(AppPMEvent.VIEW_ADDED);
dispatcher.dispatchEvent(event);
}
public function addModuleLoader(value:ModuleLoader):void
{
view.modulesContainer.addChild(value);
}
}
}
modules: FirstModule
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ns="http://swiz.swizframework.org"
xmlns:conf="swiz.modules.FirstModule.swiz.conf.*"
width="100%"
height="100%" >
<fx:Declarations>
<ns:Swiz id="mySwiz" >
<ns:beanProviders>
<conf:FirstModuleBeans/>
</ns:beanProviders>
<ns:config>
<ns:SwizConfig viewPackages="swiz.modules.FirstModule.*"
eventPackages="swiz.modules.FirstModule.events.*"/>
</ns:config>
</ns:Swiz>
</fx:Declarations>
<fx:Script>
<![CDATA[
import swiz.modules.FirstModule.swiz.pm.FirstModulePM;
[Inject]
public var pm:FirstModulePM;
protected function btn_clickHandler(event:MouseEvent):void
{
trace("pm = "+pm);
log.appendText("pm = "+pm);
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
<s:Label text="first module"/>
<s:Button label="Load second module"
id="btn"
click="btn_clickHandler(event)"/>
<s:TextArea id="log"/>
</s:VGroup>
first module swiz config
<?xml version="1.0" encoding="utf-8"?>
<swiz:BeanProvider xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:swiz="http://swiz.swizframework.org"
xmlns:pm="swiz.modules.FirstModule.swiz.pm.*">
<!-- PM -->
<pm:FirstModulePM id="pm"/>
first module PM (prezentation Model)
package swiz.modules.FirstModule.swiz.pm
{
import flash.events.IEventDispatcher;
public class FirstModulePM
{
[Dispatcher]
public var dispatcher:IEventDispatcher;
}
}
Upvotes: 0
Views: 112
Reputation: 520
What errors are you getting with the release version? If it can't find certain classes, they probably get omitted when building the release because there's no link to them. Try adding the compile flag "link-report filename" to see if all required classes are in there to make your application work. More info Examining linker dependencies.
To link them forcefully just add an import in the main application to the missing classes. Be careful when you organize imports.
Upvotes: 0