tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/44-trouble-understanding-event-injection-as-seen-in-robotlegsdemosflashgooglemapsRobotlegs: Discussion 2018-10-18T16:35:08Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/9043872010-01-24T23:35:12Z2010-01-24T23:35:12Ztrouble understanding event injection as seen in robotlegs.demos.flashgooglemaps<div><p>The CommandMap sets up a temporary rule that maps the event (by
it's concrete class) for injection just before execute() is
called:</p>
<p><a href=
"http://github.com/robotlegs/robotlegs-framework/blob/master/src/org/robotlegs/base/CommandMap.as#L154">
http://github.com/robotlegs/robotlegs-framework/blob/master/src/org...</a></p>
<p>The injection must be exactly the same event class that triggers
the Command. So, if this triggers the command:</p>
<pre>
dispatch(new CrazyEvent(CrazyEvent.BOOM));
</pre>
<p>The injection in the command must be specified like this:</p>
<pre>
[Inject] public var event:CrazyEvent;
</pre>
<p>This will not work:</p>
<pre>
[Inject] public var event:Event;
</pre>
<p>Hope that helps. Let me know if you're still getting an
error.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/9043872010-01-25T10:02:31Z2010-01-25T10:04:23Ztrouble understanding event injection as seen in robotlegs.demos.flashgooglemaps<div><p>thanks much for your explanation.</p>
<p>my code now works, but I had to:<br>
<code>commandMap.mapEvent(ModelEvent.REQUEST_LOAD,
RequestLoadCommand, ModelEvent);</code><br>
via:<br>
<code>dispatchEvent(new
ContextEvent(ContextEvent.STARTUP));</code></p>
<p>previously I had this in my Context::startup:<br>
<code>commandMap.mapEvent(ModelEvent.REQUEST_LOAD,
RequestLoadCommand, ModelEvent);<br>
super.startup();</code></p>
<p>... somehow the mapping needs to be done in response to
ContextEvent.STARTUP rather than Context.startup</p></div>%