tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/341-event-listeners-are-not-working-if-declared-without-event-argumentRobotlegs: Discussion 2018-10-18T16:35:29Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T12:18:46Z2011-07-03T12:18:46ZEvent listeners are not working if declared without event argument<div><p>Hi Dimitri, that's a requirement of AS3 event listeners. The
eventMap only handles the registering of your listener, it doesn't
do anything fancy beyond that, so it's not a bug, just a
characteristic of AS3.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T12:22:46Z2011-07-03T12:22:47ZEvent listeners are not working if declared without event argument<div><p>Oh yeah, sure.<br>
Then I'd suggested to write about it explicitly somewhere (Best
Practices?), or throw some kind of error in runtime. It took me
about 2hrs for to figure out why my Mediator stopped to receive
events.</p>
<p>Thanks for a quick reply. =)</p></div>Dimitritag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T12:27:57Z2011-07-03T12:27:57ZEvent listeners are not working if declared without event argument<div><p>Hi Dimitir,</p>
<p>it should have thrown a runtime error - along the lines of "the
function wasn't expecting an argument and one was received" - this
is built in to AS3.</p>
<p>I frequently forget to add the event to the handler and always
see this error. It's not thrown by robotlegs but by the flash
player. To throw it from robotlegs we'd have to do some sort of
reflection on the handler which would be really performance
sapping.</p>
<p>The reason it isn't mentioned in the best practices is probably
just that it's normal AS3 practice to have to declare the event in
a handler... are you new to AS3? I'm not aware of it having
confused anyone in the past - which doesn't mean that it hasn't,
they might just not have brought it to our attention.</p>
<p>I'll just confirm that I do still see the 'function args' error
myself...</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T12:32:44Z2011-07-03T12:32:44ZEvent listeners are not working if declared without event argument<div><p>Hi Dimitri - I just confirmed that it does throw an error - for
example:</p>
<pre>
<code>ArgumentError: Error #1063: Argument count mismatch on
mosaic.view::MosaicToolViewMediator/showGridOnView(). Expected 0, got 1.</code>
</pre>
<p>The only reason you wouldn't see the error is if you were
wrapping something in a try {} block, or if you are 'testing' in
browser using your non-debug release of the swf... which would be a
really strange thing to do!</p>
<p>It sounds to me like your development environment or practice is
broken - it's certainly nothing to do with robotlegs if you're not
seeing that error message.</p>
<p>Can you confirm what you're doing that <em>doesn't</em> produce
the error?</p>
<p>Thanks,</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T12:35:39Z2011-07-03T12:35:40ZEvent listeners are not working if declared without event argument<div><p>Uhm, well, no, I'm no new to AS3, actually coding since
Macromedia Flash 4.</p>
<p>I'm pretty much aware of requirement for event handler to have
event argument, i'm just new to RL, and see these listeners, not
exactly as listeners, but more like processors. You can see it by
naming, with EventListeners, i'd used something like
'onApplicationPing' instead of 'answerThePing'. Sorry for that
mental glitch. =)</p>
<p>Regarding throwing an error by FP - crap, just came on my mind -
that's because of Chrome built-in player. =( Have to install debug
version. Sorry. Anyway - you're right, it has nothing to do with
RL. Thank you a lot. =)</p></div>Dimitritag:robotlegs.tenderapp.com,2009-10-18:Comment/83622712011-07-03T17:42:56Z2011-07-03T17:42:56ZEvent listeners are not working if declared without event argument<div><p>I expect a lot of people may have that mental glitch and then
they get their first "duh, you missed the event parameter" error
and it clears it up... so I'll make a note to add it to the
getting-started docs.</p>
<p>Ah - naughty chrome player! I'm glad you got it sorted.</p>
<p>Stray</p></div>Stray