Modular Utility causing Error #1065: Variable FooterView is not defined.

Weyert's Avatar

Weyert

12 Jul, 2011 10:12 AM

I am currently trying to get a module loaded in my application and I am having a issue with the injection. I have created parentInjector property in the document class which then initiates my context derived from the ModuleContext class.

Only when I now try to load in my module I am having the following error:

ReferenceError: Error #1065: Variable FooterView is not defined.
at flash.system::ApplicationDomain/getDefinition()
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/applyInjection() 
[E:\no_flare_core\workspace\flash\contrib\SwiftSuspenders\org\swiftsuspenders\injectionpoints\PropertyInjectionPoint.as:35]

It's failing for two classes called FooterView and BackgroundView. I am already have a view mapped BackgroundView in the main application. I am capable to create an instance of FooterView in the document class of my module. It's really something strange going on in the injection.

Do I need to load the module in a different application domain?

  1. 1 Posted by Weyert on 12 Jul, 2011 10:23 AM

    Weyert's Avatar

    Mediator mappings in the module:

            mediatorMap.mapView( BackgroundView, BackgroundViewMediator, BackgroundView);
            mediatorMap.mapView( HeaderView, HeaderViewMediator, HeaderView );
            mediatorMap.mapView( FooterView, FooterViewMediator, FooterView );
    

    Looks like its tries to get a definition of the class in the wrong application domain. My SWF gets loaded with the following LoaderContext:

        new LoaderContext(true, new ApplicationDomain(ApplicationDomain.currentDomain), SecurityDomain.currentDomain)
    
  2. 2 Posted by neil on 12 Jul, 2011 10:29 AM

    neil's Avatar

    OK, with out digging deep at all, I notice you state:

    "I have created parentInjector property in the document class which then initiates my context derived from the ModuleContext class."

    (I'm assuming youj are using Joels modular util) The IModule specifies:
    function set parentInjector(value:IInjector):void;

    so the ModuleContext should be creating the child Injector for you??

    can you paste some code?
    or if you can't can you paste me some in chat?

  3. 3 Posted by neil on 12 Jul, 2011 10:30 AM

    neil's Avatar

    Isn't there an ApplicationDomain prop that you can set?

  4. 4 Posted by neil on 12 Jul, 2011 10:32 AM

    neil's Avatar

    yep, you can pass in an ap domain in the create child
    injector.createChild(_applicationDomain)

  5. 5 Posted by neil on 12 Jul, 2011 10:34 AM

    neil's Avatar

    ok, the Application view is retrieved from the contextView
    so the question, what view do you supply to your ModuleConext?

  6. 6 Posted by Weyert on 12 Jul, 2011 10:36 AM

    Weyert's Avatar

    My code is the following (ISequenceItemView introduces the dispose method):

    /**
     * Application Entry Class
     */
    public class my_module extends Sprite implements ISequenceItemView {
    
        protected var context: DrawingModuleContext;
    
        [Inject]
        public function set parentInjector(value:IInjector):void
        {
            trace("DrawingModule.parentInjector(): value=" + value);
            context = new MyModuleContext( this, true, value );
        }
    
        /**
         * Constructor
         */
        public function my_module() {
            super();
        }
    
        /**
         * @inheritDoc
         */
        public function dispose():void
        {
            if ( context )
            {
                context.shutdown();
    
            }
            trace("DrawingModule.dispose()");
        }
    

    }

  7. 7 Posted by Weyert on 12 Jul, 2011 10:47 AM

    Weyert's Avatar

    I changed my code with the following code snippet:

        [Inject]
        public function set parentInjector(value:IInjector):void
        {
            trace("DrawingModule.parentInjector() 1: value=" + value);
            trace("DrawingModule.applicationDomain 2: " + this.loaderInfo.applicationDomain );
            trace("DrawingModule.applicationDomain 3: " + this.loaderInfo.applicationDomain.getDefinition('ch.nothing.swisslos.subito.modules.drawing.views.elements.BackgroundView') );
            context = new DrawingModuleContext( this, true, value );
        }
    

    and then it correctly creates an instance:

       DrawingModule.parentInjector() 1: value=[object SwiftSuspendersInjector]
      DrawingModule.applicationDomain 2: [object ApplicationDomain]
      DrawingModule.applicationDomain 3: [class BackgroundView]
      DrawingModuleContext.construct()
    

    I am not sure what I am doing wrong. The error happens in the following line of code:

            //
            var topLayer: Sprite = new Sprite();
            topLayer.name = "top";
            var contentLayer: Sprite = new Sprite();
            contentLayer.name = "content";
            var bottomLayer: Sprite = new Sprite();
            bottomLayer.name = "bottom";
    
            topLayer.addChild( new FooterView() );
            topLayer.addChild( new HeaderView() );
            bottomLayer.addChild( new BackgroundView() );
    
            contextView.addChild( bottomLayer );
            contextView.addChild( contentLayer );
            contextView.addChild( topLayer );
    
  8. 8 Posted by Weyert on 12 Jul, 2011 10:51 AM

    Weyert's Avatar

    ok, the Application view is retrieved from the contextView so the question, what view do you supply to your ModuleConext?

    I am supplying the document class to the module context.

  9. 9 Posted by neil on 12 Jul, 2011 11:10 AM

    neil's Avatar

    ok, I think we can assume that this is an ApplicationDomain problem.
    What we need to determine is if this has anything to do with RL or SS or neither.
    Does the error get thrown when a new FooterView is created? or when RL and SS try and automatically mediate it?

    ie
    var footer:FooterView = new FooterView()
    topLayer.addChild( footer );

    where does it chuck that error?

  10. 10 Posted by Weyert on 12 Jul, 2011 11:25 AM

    Weyert's Avatar

    Yes, I don't have the problem when I kickstart the module without loading into the shell or when I disable the mediator mappings. The code for loading a module is the following:

        _contentURL = contentURL;
    
        var context: LoaderContext = new LoaderContext();
        context.checkPolicyFile = true;
        context.applicationDomain = new ApplicationDomain( ApplicationDomain.currentDomain );
    

    public function load(contentURL: String):void
    {

        trace("ModuleSequenceItemView.load(): contentURL=" + _contentURL );
        _movieLoader = new Loader();
        _movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onContentLoaded);
        _movieLoader.load( new URLRequest( contentURL ), context );
    

    }

    /**
     * @inheritDoc
     */
    protected function onContentLoaded(event: Event):void
    {
        var module: ISequenceItemView = _movieLoader.content as ISequenceItemView;
        _moduleView = _movieLoader.content as Sprite;
    
        // inject into the module class so that parentInjector gets called
        if ( injector ) injector.injectInto( _moduleView );
    
        if ( module ) {
            module.setSequenceItem( _sequenceItem );
            module.load( _contentURL );
        } else {
            trace("MODULE MISSING ISequenceItemView module implementation");
        }
        this.addChild( _movieLoader.content );   
    }
    

    I am not sure what I am doing wrong. The only thing that probably is different that I don't map all the modules which is problematic because I don't know which modules will exist in the future.

  11. Weyert closed this discussion on 18 Jul, 2011 10:20 AM.

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