Reputation: 5463
using robotlegs i always retrieve this error. I have not idea whats wrong.
TypeError: Error #1009: Cannot access a property or method of a null object reference. at org.robotlegs.mvcs::Actor/dispatch()[/Users/shaun/Documents/ Development/Workspaces/GanymedeFB4/robotlegs-framework/src/org/ robotlegs/mvcs/Actor.as:57]
Model
package com.something.model {
// someimports
public class PhotoModel extends Actor {
public function uploadAndDetect() : void {
// something
dispatch(new DetectEvent(DetectEvent.DETECTED));
}
}
}
Event
package com.something.events {
// someimports
public class DetectEvent extends Event {
public static const DETECTED : String = "DETECTED";
public function DetectEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false){
super(type, bubbles, cancelable);
}
override public function clone():Event{
return new DetectEvent(type, bubbles, cancelable);
}
}
}
Upvotes: 0
Views: 733
Reputation: 370
When and where are creating the Model? I bet that your are not injecting its dependencies. The model should be created in a Command and the use:
var model: PhotoModel = new PhotoModel();
injector.injectInto(model);
And then the eventDispatcher (the only dependency of Actor) should be injected.
Upvotes: 0
Reputation: 6961
I can't read German well enough to be sure, but I'd suspect that the issue is that your Model isn't getting injected with the Event Bus (IEventDispatcher shared by just about everything Robotlegs needs to communicate with).
How are you instantiating this? Are you running this from a Unit test? If so, you need to set the eventDispatcher on your Model. If not, you need to use mapClass, mapSingleton, or mapSingletonOf to make sure your Model gets instantiated with the things it needs to work as an Actor.
Upvotes: 2