I have code in my application that must run prior to Swiz initializing any Beans. I have placed the code in a function that is triggered on the Application preinitialize event, but Swiz starts to initialize beans before that code executes. The relevant portions of my application's mxml file is as follows:
The "preinit" code is loading server config information from an xml file -- all of my beans depend on that information being there. I've set breakpoints on the first line of both preinit() and configureChannels(), and I get an error from one of my bean classes before either breakpoint trips.
Any help would be greatly appreciated -- thank you!
<?xml version="1.0" encoding="utf-8"?>
<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:view="org.vertex.view.*"
xmlns:swiz="http://swiz.swizframework.org"
xmlns:config="org.vertex.config.*"
minHeight="0" minWidth="0"
height="100%" width="100%"
skinClass="org.vertex.skins.ApplicationContainerSkin"
xmlns:form="org.vertex.form.*"
xmlns:editComponents="org.vertex.editComponents.*"
preinitialize="preinit(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import mx.controls.Alert;
import mx.controls.menuClasses.MenuBarItem;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
import mx.messaging.ChannelSet;
import mx.messaging.channels.RTMPChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.states.State;
import org.vertex.AppModel;
[Inject(bind="true",twoWay="true")]
[Bindable]
public var appModel:AppModel;
public var cs:ChannelSet;
public function genericFault(fe:FaultEvent):void
{
//Alert.show(fe.message.toString());
var popup:DiagnosticView = new DiagnosticView();
popup.errorString = fe.message.toString();
PopUpManager.addPopUp(popup, FlexGlobals.topLevelApplication.contentGroup, true);
PopUpManager.centerPopUp(popup);
}
protected function preinit(event:FlexEvent):void
{
var configSrv:HTTPService = new HTTPService();
configSrv.url="channels.xml";
configSrv.resultFormat="e4x";
configSrv.addEventListener(ResultEvent.RESULT, configureChannels);
configSrv.send();
}
public function configureChannels(event:ResultEvent):void {
var xml:XML = event.result as XML;
xml.channel.(trace(@id));
var centralRTMP:String = "" + xml..channel.(@id=="my-rtmp").@endpoint;
var localRTMP:String="" + xml..channel.(@id=="local-rtmp").@endpoint;
if(localRTMP == "" || localRTMP == "") {
Alert.show("Channel configuration error");
}
else {
cs = new ChannelSet();
cs.addChannel(new RTMPChannel("my-rtmp", centralRTMP));
cs.addChannel(new RTMPChannel("local-rtmp", localRTMP));
}
}
]]>
</fx:Script>
<fx:Declarations>
<swiz:Swiz>
<swiz:beanProviders>
<config:Beans/>
</swiz:beanProviders>
<swiz:config>
<swiz:SwizConfig eventPackages="org.vertex.event"
viewPackages="org.vertex.view,org.vertex.presentationmodel,org.vertex.form,org.vertex.editComponents"
defaultFaultHandler="{genericFault}"/>
</swiz:config>
</swiz:Swiz>
</fx:Declarations>
--
You received this message because you are subscribed to the Google Groups "Swiz Framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swiz-framework/-/pOrDu4ZSOfsJ.
To post to this group, send email to swiz-fr...@googlegroups.com.
To unsubscribe from this group, send email to swiz-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swiz-framework?hl=en.