tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/34-error-dispatching-event-when-application-loadsRobotlegs: Discussion 2018-10-18T16:35:08Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/8850522010-01-20T19:57:43Z2010-01-20T19:57:47ZError dispatching event when application loads<div><p>Hi there. I'm having an issue dispatching an event when an
application starts.<br>
I have a ViewManager and ViewManagerMediator.<br>
In the override public function onRegister() on the
ViewManagerMediator, I am dispatching the following event.<br>
dispatch( new ApplicationLoadEvent(
ApplicationLoadEvent.APPLICATION_LOAD_IN_PROGRESS ) );</p>
<p>The corresponding Command that is mapped in my Context is
ApplicationLoadCommand and looks like this.<br></p>
<pre>
<code> [Inject]
public var model : AppModel;
[Inject]
public var service : IServiceDelegate;
override public function execute():void
{
model.account = contextView.root.loaderInfo.parameters.account;
model.transaction = contextView.root.loaderInfo.parameters.transactionID;
model.route = contextView.root.loaderInfo.parameters.routeID;
if( model.route.length > 1 ) {
model.transactionInfo = "<b>Account:</b> " + model.account + " - " +
"<b>Transaction ID:</b> " + model.transaction + " - " +
"<b>Route ID:</b> " + model.route;
}
else {
model.transactionInfo = "<b>Account:</b> " + model.account + " - " +
"<b>Transaction ID:</b> " + model.transaction ;
}
model.isNewRouteUpdate = ( model.transaction == '0' );
service.loadJurisdictions();
}</code>
</pre>
<p>The purpose here is to grab some variables from the FlashVars
and insert them into the Model.<br>
It all works perfect in development, but when it is deployed to the
webserver, I get the following error.</p>
<pre>
<code>TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.lacsd.controls::ApplicationLoadCommand/execute()
at org.robotlegs.base::CommandMap/routeEventToCommand()
at MethodInfo-3324()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.robotlegs.mvcs::Mediator/dispatch()
at org.lacsd.view.mediators::ViewManagerMediator/onRegister()
at org.robotlegs.base::MediatorBase/preRegister()
at org.robotlegs.base::MediatorMap/registerMediator()
at org.robotlegs.base::MediatorMap/createMediator()
at org.robotlegs.base::MediatorMap/onViewAdded()
at flash.display::DisplayObjectContainer/addChildAt()
at mx.managers::SystemManager/preloader_preloaderDoneHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/displayClassCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::DownloadProgressBar/timerHandler()
at mx.preloaders::DownloadProgressBar/initCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/dispatchAppEndEvent()
at mx.preloaders::Preloader/appCreationCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()
at mx.core::UIComponent/callLaterDispatcher()</code>
</pre>
<p>If I click on Dismiss All or Continue in the Error window, the
application still works just fine, all my values are updated and I
can continue use as normal. I suspect the error is because I am
dispatching the event too soon.<br>
I tried to dispatch the ApplicationLoadEvent from my Views
addedToStage event, from the Context startup(), but they all yield
the same result. If I remove the ApplicationLoadEvent, I get no
errors, but I also cannot pass the flashVars I need to start my
application. Is there something I am missing here?</p>
<p>The deployment site is not public unfortunately, so I can't
provide the full application.</p>
<p>Thank you in advance for any assistance.</p></div>Renetag:robotlegs.tenderapp.com,2009-10-18:Comment/8850522010-01-20T20:25:43Z2010-01-20T20:25:47ZError dispatching event when application loads<div><p>After some tinkering, I think it may have to do with the
formatting of the flashvars my Consultant is using.</p>
<p>They are using<br>
FlashVars", "account=" + accnum +"&transactionID=" + tranid
+"&routeID=" +routeid,</p>
<p>But based off my test environment, I think it should be<br>
FlashVars", "account=" + accnum +"&transactionID=" + tranid
+"&routeID=" +routeid,</p>
<p>I'm meeting with them later today to see if this will solve the
problem. I will post an update, and if that was the issue, I am
sorry for taking up your time.</p></div>Renetag:robotlegs.tenderapp.com,2009-10-18:Comment/8850522010-01-23T01:22:39Z2010-01-23T02:05:08ZError dispatching event when application loads<div><p>As it turns out, the deployed app was using an older version of
my swf that was compiled using<br>
Application.application.parameters</p>
<p>as opposed to</p>
<p>contextView.root.loaderInfo.parameters</p>
<p>Incidentally, I would not have known to use the contextView
version were it not for a discussion I saw on here a week or so
ago. Thanks.<br>
Sorry for the bother.</p></div>odoe