Error dispatching event when application loads

Rene's Avatar

Rene

20 Jan, 2010 07:57 PM

Hi there. I'm having an issue dispatching an event when an application starts.
I have a ViewManager and ViewManagerMediator.
In the override public function onRegister() on the ViewManagerMediator, I am dispatching the following event.
dispatch( new ApplicationLoadEvent( ApplicationLoadEvent.APPLICATION_LOAD_IN_PROGRESS ) );

The corresponding Command that is mapped in my Context is ApplicationLoadCommand and looks like this.

    [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();
    }

The purpose here is to grab some variables from the FlashVars and insert them into the Model.
It all works perfect in development, but when it is deployed to the webserver, I get the following error.

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()

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.
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?

The deployment site is not public unfortunately, so I can't provide the full application.

Thank you in advance for any assistance.

  1. 1 Posted by Rene on 20 Jan, 2010 08:25 PM

    Rene's Avatar

    After some tinkering, I think it may have to do with the formatting of the flashvars my Consultant is using.

    They are using
    FlashVars", "account=" + accnum +"&transactionID=" + tranid +"&routeID=" +routeid,

    But based off my test environment, I think it should be
    FlashVars", "account=" + accnum +"&transactionID=" + tranid +"&routeID=" +routeid,

    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.

  2. 2 Posted by odoe on 23 Jan, 2010 01:22 AM

    odoe's Avatar

    As it turns out, the deployed app was using an older version of my swf that was compiled using
    Application.application.parameters

    as opposed to

    contextView.root.loaderInfo.parameters

    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.
    Sorry for the bother.

  3. Till Schneidereit closed this discussion on 23 Jan, 2010 06:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac