adding listener to StaticEventBus throws "Argument count mismatch" error on listener function

51 views
Skip to first unread message

Yennick Trevels

unread,
May 22, 2013, 8:49:17 AM5/22/13
to as3-commons...@googlegroups.com
When adding an eventListener on the StaticEventBus I immediately get an "Argument count mismatch" error because the logger is trying to call the listener function.
I'm using:
  • commons-logging 2.7
  • commons-eventbus 1.4.0
  • Flex 4.5
This is the stacktrace:
ArgumentError: Error #1063: Argument count mismatch on MainTest/eventBus_loggedInHandler(). Expected 1, got 3.
at String$/_replace()
at mx.logging::LogLogger/debug()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\logging\LogLogger.as:153]
at org.as3commons.logging.setup.target::FlexLogTarget/log()[C:\projects\as3-commons\as3-commons-logging\src\main\actionscript\org\as3commons\logging\setup\target\FlexLogTarget.as:59]
at org.as3commons.logging.api::Logger/debug()[C:\projects\as3-commons\as3-commons-logging\src\main\actionscript\org\as3commons\logging\api\Logger.as:84]
at org.as3commons.eventbus.impl::SimpleEventBus/addEventListener()[C:\projects\as3-commons\as3-commons-eventbus\src\main\actionscript\org\as3commons\eventbus\impl\SimpleEventBus.as:90]
at org.as3commons.eventbus.singleton::StaticEventBus$/addEventListener()[C:\projects\as3-commons\as3-commons-eventbus\src\main\actionscript\org\as3commons\eventbus\singleton\StaticEventBus.as:61]
at MainTest/initializeHandler()[C:\myprojects\aviga-trunk\aviga-client\src\main\actionscript\MainTest.mxml:36]
at MainTest/___MainTest_Application1_creationComplete()[C:\myprojects\aviga-trunk\aviga-client\src\main\actionscript\MainTest.mxml:4]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.core::UIComponent/set initialized()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:1818]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:842]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]


I also created a small testcase which reproduces the error:

<?xml version="1.0"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:mx="library://ns.adobe.com/flex/mx"
                creationComplete="initializeHandler(event)">

    <fx:Script>
<![CDATA[
        import mx.events.FlexEvent;
        import mx.logging.Log;
        import mx.logging.LogEventLevel;
        import mx.logging.targets.TraceTarget;

        import org.as3commons.eventbus.singleton.StaticEventBus;
        import org.as3commons.logging.api.LOGGER_FACTORY;
        import org.as3commons.logging.setup.SimpleTargetSetup;
        import org.as3commons.logging.setup.target.FlexLogTarget;

        use namespace LOGGER_FACTORY;

        setupLogging();

        private static function setupLogging():void {
            LOGGER_FACTORY.setup = new SimpleTargetSetup(new FlexLogTarget());

            var traceTarget:TraceTarget = new TraceTarget();
            traceTarget.includeCategory = true;
            traceTarget.includeDate = true;
            traceTarget.includeLevel = true;
            traceTarget.includeTime = true;
            traceTarget.level = LogEventLevel.INFO;

            Log.addTarget(traceTarget);
        }

        private function initializeHandler(event:FlexEvent):void {
            StaticEventBus.addEventListener("loggedIn", eventBus_loggedInHandler);
        }

        private function eventBus_loggedInHandler(event:Event):void {

        }
        ]]>
</fx:Script>

</mx:Application>


Anyone has an idea why this is going wrong?

Thanks.

Roland Zwaga

unread,
May 22, 2013, 9:40:28 AM5/22/13
to as3-commons...@googlegroups.com
This seems to be an issue with the FlexLogTarget, have you tried just using the TraceTarget like this?

LOGGER_FACTORY.setup = new SimpleTargetSetup(new TraceTarget());

I personally never use the Flex logger, so I never ran into the issue, apparently the Flex logger can't
take a Function argument, I've looked ta the code briefly but I can't figure out why its actually
invoking the function.

Yennick Trevels

unread,
May 22, 2013, 10:21:21 AM5/22/13
to as3-commons...@googlegroups.com
No, didn't try that before. Wish I did because it works ;) Thanks!
It was also a mystery to me why it was calling the function when looking at the source code.
Reply all
Reply to author
Forward
0 new messages