Creating an Actor instance - has no eventDispatcher?

jamesr's Avatar

jamesr

06 Aug, 2010 10:06 PM

Hi,

if i map a Class that extends Actor using the code below, the next time i inject that Class and inspect the instance it has an eventDispatcher set on it.

injector.mapSingleton( myActorSubClass );

However, if i map an instance of a Class that extends Actor using the code below, the next time i inject it, it has no eventDispatcher set on it and i get an error when i try to call dispatch? From what i've read, the eventDispatcher is injected into the Actor instance so that it's hooked up to the framework. Is the result i'm getting expected behaviour, or am i doing something wrong?

injector.mapValue( myActorSubClass, myActorSubClassInstance );

Cheers,

James

  1. Support Staff 1 Posted by Joel Hooks on 06 Aug, 2010 11:11 PM

    Joel Hooks's Avatar

    mapSingleton injects into the instance when it is created by the DI container. mapValue does not and assumes you have already taken care of that.

    injector.mapValue( myActorSubClass, injector.injectInto(myActorSubClassInstance) );

    that woud do it. or:

    var myValue:MyClass = injector.instantiate(MyClass);
    injector.mapValue(MyClass, myValue);

  2. 2 Posted by jamesr on 07 Aug, 2010 11:19 AM

    jamesr's Avatar

    Cheers Joel, apologises for what in hindsight was a fairly simplistic question, i'm pretty stacked at the moment porting a large existing project to Robot Legs.

    It's going very smooth so far, a testament to how simple RL is to use and implement. Thanks a lot.

  3. Stray closed this discussion on 10 Feb, 2011 05:33 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