Model gets injected but it's properties and methods are undefined

Igor's Avatar


26 Sep, 2010 01:23 PM

Hi there,

This is my first robotlegs project and I have looked through several posts where people seemed to have a similar problem but still haven't found a solution.

In my Context, I am using mapSingletonOf() to map a Service injected into used by StartupCommand and Model injected into and used by PopulateModelCommand.

override public function startup ():void

commandMap.mapEvent(ContextEvent.STARTUP_COMPLETE, StartupCommand, ContextEvent);
commandMap.mapEvent(DataEvent.GALLERY_LOADED, PopulateModelCommand, DataEvent);

injector.mapSingletonOf(IBPModel, BPModel);
injector.mapSingletonOf(IDataService, XMLLocalService);

mediatorMap.mapView(Main, MainMediator);



XMLLocalService gets injected and I can access it's method loadData() no problem at all. See below.

public class StartupCommand extends Command

public var service:IDataService;

override public function execute ():void


However when I try and use BPModel

public class PopulateModelCommand extends Command

public var model:IBPModel;

public var event:DataEvent;

override public function execute() : void
    trace("PopulateModelCommand, model=" + model);
    // =;


the model gets injected (I get a trace model=[object BPModel] but when I try and access any of the model's properties/methods I get a compiler error col: 10 Error: Call to a possibly undefined method test.

Both BPModel and XMLLocalService extend Actor. Why can I access the methods in a service but can't in my model? What am I doing wrong?

I am using RL swc 1.3.0. My compiler is set to keep [Inject] and [PostConstruct]. Below is the full stack I am getting when I am trying to compile the project.

mxmlc -load-config+=obj\BPLandingPageConfig.xml -debug=true -incremental=true -benchmark=false -keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct -o obj\BPLandingPage634210368560312500
Incremental compile of 1
Loading configuration file C:\Program Files\Flex3SDK\frameworks\flex-config.xml Loading configuration file ... BPLandingPageConfig.xml
Recompile: ...
Reason: The source file or one of the included files has been updated.
Reason: The source file or one of the included files has been updated.
Files changed: 2 Files affected: 0
(fcsh) ... col: 10 Error: Call to a possibly undefined method test. model.test();
^ Build halted with errors (fcsh).
Done (1)

Many thanks for your help in advance.

  1. Support Staff 1 Posted by Ondina D.F. on 26 Sep, 2010 02:13 PM

    Ondina D.F.'s Avatar

    Hi Igor,

    It’s a name collision ( var model and package name model ):

    import model.IBPModel;
    [Inject] public var model:IBPModel;

    Try to change the var model to something else, say
    public var bpModel: IBPModel;
    and it will work.


  2. Support Staff 2 Posted by Ondina D.F. on 26 Sep, 2010 02:16 PM

    Ondina D.F.'s Avatar

    And don’t call test() in the constructor:
    public function BPModel()
    { test();


  3. 3 Posted by Igor on 26 Sep, 2010 02:21 PM

    Igor's Avatar

    Ondina. Amazing, thank you so much. What was confusing me is that when I was tracing the model I was given the right type model=[object BPModel] which led me to believe I was dealing with the right object and no name collision was happening.


  4. 4 Posted by Igor on 26 Sep, 2010 02:22 PM

    Igor's Avatar

    Btw. When I was calling test() in the constructor it would fire OK as I expected.

  5. Stray closed this discussion on 10 Feb, 2011 05:51 PM.

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

Keyboard shortcuts


? 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