Injected into Command service is null

dev.div0's Avatar


20 Sep, 2015 12:04 PM

Please point to my error.
the config is:

`[Inject] public var injector:IInjector;

public function configure():void


    private function initComplete():void
        dispatcher.dispatchEvent(new ConfigEvent(ConfigEvent.CONFIG_INIT_COMPLETE));

`public class SaveDataCommand extends Command{

public var service:IService;

public function SaveDataCommand() {
    trace("service = "+service);
        trace("Service is NULL");


} }`

`package { import com.gamua.flox.Flox;

public class FloxService implements IService {

public function saveGoToMainCount(count:int):void {
    Flox.logEvent("go_main_clicked", {count: count});

public function saveGoToIntroClick():void {

public function saveData():void {
    Flox.getTime(getTimeCompleteHandler, getTimeErrorHandler);

private function getTimeErrorHandler(error:String, httpStatus:int):void {
        trace("saveData error:"+error +".  httpStatus:"+httpStatus);

    private function getTimeCompleteHandler(time:Date):void {
        new SaveData(time.toString());


in case of service's interface injection

[Inject] public var service:IService;

the error is

Error: Injector is missing a mapping to handle injection into property "service" of object "[object SaveDataCommand]" with type "dev.div0.commands::SaveDataCommand". Target dependency: "|"

in case of class injection

[Inject] public var service:FloxService;

service is NULL

  1. Support Staff 1 Posted by Ondina D.F. on 20 Sep, 2015 12:47 PM

    Ondina D.F.'s Avatar

    Hi,; is an incomplete mapping.

    The correct mapping would be:;

    Please read the answers from the following discussions for more details:

    Also, be aware of the differences between the different mappings :

    toValue - Makes the mapping return the given value for each consecutive request.

    toType - Makes the mapping return a newly created instance of the given type for each consecutive request.

    toSingleton - Makes the mapping return a lazily constructed singleton instance of the mapped type for each consecutive request.

    asSingleton - Makes the mapping return a lazily constructed singleton instance of the mapped type for each consecutive request.

    asSingleton(initializeImmediately:Boolean=false) - initializeImmediately determines when the instance should be created, immediately after mapping or after the first request

    Hope this helps.

  2. Support Staff 2 Posted by Ondina D.F. on 20 Sep, 2015 12:50 PM

    Ondina D.F.'s Avatar

    I forgot to say that if you are injecting an interface, you should map it like this:;
  3. 3 Posted by dev.div0 on 20 Sep, 2015 01:21 PM

    dev.div0's Avatar

    Thank you.
    By the way - its my error.
    I need to override execute() method to use injected service inside Command - my inattention.

  4. Support Staff 4 Posted by Ondina D.F. on 21 Sep, 2015 03:45 PM

    Ondina D.F.'s Avatar

    You're welcome!

    Concerning the execute method in commands, I didn't notice that you didn't have an execute() in your command. I spotted the incomplete mapping and didn't pay much attention to the code below it.

    So yes, injected classes will be null within a constructor, because the Injector hasn't finished its job (injection) yet:

    Just for your information, you don't need to extend the robotlegs Command class. Any class with a public execute method can be used as a Command.

    I'm going to mark this discussion as resolved, but you can re-open it, if need be, or you can create a new discussion if you need assistance on another topic.


  5. Ondina D.F. closed this discussion on 21 Sep, 2015 03:45 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